Navigation bug when tabbing out of browser, maybe?
I am currently developing an app with Tanstack Router, and I love it! But I am encountering one problem. Whenever I move my browser out of focus (By clicking on another app on my pc), and then click on my browser again, I am not able to navigate to other pages? I can click my navigation buttons, and the URL in my browser changes, but the content of my app does not change to the new page?
I am not getting any errors, or any other information, so I do not expect to get an answer. I am just curious if anyone has experienced this before?
5 Replies
quickest-silver•2y ago
can you provide a minimal complete example?
afraid-scarletOP•2y ago
Yes of course:
This is the main.tsx file:
And here is the root.tsx file (I have double underscore before root, but discord formats it wrong):
I am suspecting that the problem may lie in the fact that my providers are located both in main.tsx, and in __root.tsx. But for some reason my app will not load if I put QuerProvider & UserProvider in main.tsx. Would it make a difference to move them to main.tsx?
quickest-silver•2y ago
can you please make it runnable e.g. by forking one of the router examples on Stackblitz and modifying it?
btw this sounds more like a react query issue here since it has the reload on window focus feature
you could disable it and see if this problem is still occuring
quickest-silver•2y ago
Window Focus Refetching | TanStack Query Docs
If a user leaves your application and returns and the query data is stale, TanStack Query automatically requests fresh data for you in the background. You can disable this globally or per-query using the refetchOnWindowFocus option:
Disabling Globally
afraid-scarletOP•2y ago
The React Query thing did not make a change, but thank you for the suggestion 😄
I am not able to recreate the problem on stackblitz for some reason.
I have also tried building the app and running it, but that also has the same problem.