Skip to content
Discussion options

You must be logged in to vote

I do think that this is indeed a bug / not ideal behaviour of useQueries. At leat the effect dependency is superfluous because, as you said, since we .map, the effect will run in every render anyhow.

However, does running the effect really trigger another re-render? Because if that were the case, we would likely be looking at an infinite loop, because with an additional re-render, the useQueries hook would be called again, scheduling the effect again ...

If so, could it be easily fixed by wrapping the creation of defaultedQueries in a useMemo like this:

yes it could, but it would also shift the responsibilities to consumers of useQueries. Most people call it with:

useQueries(someIds.map…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ericpatey
Comment options

@ericpatey
Comment options

@TkDodo
Comment options

@ericpatey
Comment options

Answer selected by ericpatey
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