useQuery result fails to update when prefetchQuery is used inside loader
Context: I'm using React router 6 with data loaders, and the route I'm testing has 2k DOM nodes
I have a prefetchQuery on a loader and a useQuery on the same route, both using the same query, and it works great on first load, but when a prop changes and executes both prefetchQuery and useQuery it runs the queryFn correctly and gets the result on network tab and on TQ devtools but it doesn't update the useQuery result, this only happens sometimes when the page rendering from the data is complex/big enough.
It looks like there are some cases where the useQuery result update can be missed if there is a prefetchQuery firing at the same time as the useQuery and the render tree changes is slowing things down, or something like that?
Everything works perfectly if I remove the prefetchQuery.
Because it only happens when the rendering tree affected by the data is complex enough, I had a hard time making a reproduction on codesandbox. I can make a video or a call if necessary, thanks!
0 Replies