Why doesn't random value work here but static does?
Here's the code
This will keep me in the state of loading forever even tho the data is fetched. But if I remove the
getRandomId function and just set the id statically it all works. At first I thought that there was a problem with my state management, but it seems like its Tanstack Query related. Also here's the custom hook for the useQuery that I created.
2 Replies
implicit-limeOP•3y ago
Its worth noting that I'm using Next 13 with custom API routes 🙂
generous-apricot•3y ago
It looks like you're switching between random numbers on every render. Put the random number in react state.