Ok so more stupid problems from me 😅
Ok so more stupid problems from me 😅
I want to have two for-loops in a sense: one loops over the entity I call "generation" and the second one loops over "images" inside the "generation".
I'm trying to do both things with
useQuery
, in the second case I'm using results of the first one.... and react doesn't like that!
I'm getting Rendered more hooks than during the previous render
The code is roughly speaking
8 Replies
Do I need to create a new query where I mish-mash both of these things together and listen on it instead?
Ah! React can't render hooks conditionally (or change the number of hooks rendered). One way to get this working is to refactor the mapper function into its own component i.e.
That way, each list item is one component that always calls exactly one useQuery hook
hm sorry I don't fully follow -- where is the second (inner) query will happen?
Is it inside the
GenerationListItem
based on props?Yup! The
getImagesForGeneration
call would be inside GenerationListItem
Awesome, let me try that. And thank you so much for the quick replay!
No worries, I just so happened to be online on discord, gaming 😄
Let me know how it goes!
awesome, works like a charm!
yay!