I've made a custom react hook useMyElement that returns a JSX.Element and some value, i.e.
interface HookOutput {
element: JSX.Element;
value: any;
}
This works just fine but now I want to use a list of those elements and values, i.e.
const hookElements = listOfArgs.map(args => useMyElement(args))
but I realize that this is gives unintended usage. I also get the following warning
React Hook "useMyElement" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function. (react-hooks/rules-of-hooks)
How can I achieve a pattern like this? I.e. want to create a list of react components and return their stateful values from it as well without using something like redux.