QueryClient cache getting invalidated between navigation?
hello! running into a weird bug with my app. my
currentUser
state is managed in an isomorphic QueryClient
, but it seems to return inconsistent behavior throughout the app. when i am logged in:
* visiting /chat
correctly loads the active user from state
* visiting /chat
, then visiting /
, then reloading, then visiting /chat
shows i am logged out! a simple refresh corrects the state.
i think my setup is pretty straight forward, so not sure where my misstep is:
i've got a root (__root.tsx
) route defined as:
userQueryOptions
looks like this:
and i consume it with a basic hook:
my understanding is that the result of useUser
should always be fresh between navigations as we call ensureQueryData
. is this not correct?1 Reply
generous-apricotOP•4mo ago
i should note, my
queryClient
is created inside createRouter()
after some debugging, it was the staleTime
causing this issue. i don't mind removing that, but i'm curious why it would ever return null and cache? 🤷♂️