Is there a way to force data to update on a new page with t3 without having to click the page
I guess in principle this shoudn't be possible without some aspect of concurrency and clicking on the page does retrieve the data right away . But is there some way to avoid having to click on page for rerender or is that just nature of how code is rendered as I think it is?
6 Replies
Prefetch ?
i can help you narrow your search
explore react-query docs more
There's a refetch interval option
For example on the chirp app Theo built if you were to open two tabs and click on a profile and then from the other create a new tweet, the profile wont update with the new tweet until the page is clicked on again . Why is that ?
Im also guessing potentially just appending to the array of objects with [ newEntries ...prevEntries ] could work but I've been trying to do all the management strictly on the TRPC side (and i guess query.invalidate() leads to this sort of behavior)
refetch on focus is the default with react-query. you could probably trigger it on manually on click, but I've not had need to to that myself
https://tanstack.com/query/v5/docs/react/guides/window-focus-refetching
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
Thanks I think that explained it since im using multiple tabs , the query is reloading(since it is now back in focus) as I shift back to the other page and click on it!