Skip to content
Discussion options

You must be logged in to vote

it looks like array returned by useQueries has a new identity each time the hook is called and triggers the effect that has it as a dependency.

yes, it does. There's also no need to add useMemo to the queries input, that doesn't change that.

apart from that, data transformation shouldn't need useEffect and state. What you'd probably want is another useMemo instead of the useEffect. But this would suffer from the same problem: useMemo would also just run on every render.

So, long story short: There is no good, built-in way to aggregate data over a dynamic array from useQueries. If it helps, each data object inside your array will be kept referentially stable unless something changes insi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cneumann
Comment options

Answer selected by cneumann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants