React query hanging in react native (expo)
I have been trying to debug this for quite a few hours now and I am stumped. I am seeing a
useQuery hang right before it gets to a db query, but only the first time. It eventually returns data, but only after like 30+ seconds.
I am using the react native debugger and have confirmed that the network calls themselves are very short, like 100-200ms once they actually fire. But for some reason the useQuery refuses to return the data quickly. I have also added a fetch() in there and I can see the fetch call complete in the debugger, but the console.logs I have right after wont log until like 30 seconds after.6 Replies
other-emerald•2mo ago
Possible to send a code snippet? Can take a look
exotic-emeraldOP•2mo ago
Heres the wrapper for the function:
and the queryFn itself:
other-emerald•2mo ago
And all those performance times that get console logged are short?
exotic-emeraldOP•2mo ago
no, the first performance time will always be slow (ive tried by only doing one of the three operations in that example above, then slowly adding more). so the performance.now() call correctly captures how slow the return of the fn is, even though in the network tab of the debugger I can see that the network calls themselves are 100ms ish
I just added some react query dev tools as well and when this happens it shows that the fn is in a loading state
Actually I can get it hanging for a while and whenever I pull up the dev tool UI component it kind of starts to load in faster... Maybe this is a react native rendering issue of some sort
other-emerald•2mo ago
Is it possible to get a git repro so I can test it locally?
exotic-emeraldOP•2mo ago
I can try to repro but I suspect I wont be able to. Really I am just looking for more ways to debug this, or if there are any known gotchas with react native/expo navigation and react query
Ok it turned out to be an infinite re-render in my tab layout that for some reason was causing this... Took me a ton of time in the debugger to even get a hint as to this. Really appreciate your help!