T
TanStack3y ago
flat-fuchsia

Updating the cache manually sometimes does not rerender the UI

I’m working with React Query in React Native and I’ve noticed that sometimes when my queries update the cache manually on success it does not rerender. Has anyone encountered this before or is this known to happen? I’m forced to just invalidate onSettle instead to ensure the rerender happens.
2 Replies
sharp-indigo
sharp-indigo3y ago
There should be no difference if you update or a refetch updates. Make sure updates are done in an immutable way
flat-fuchsia
flat-fuchsiaOP3y ago
I just realized I had set my stale time to 2 min and removed that. I noticed that when I go to a new screen in my application any queries in there will either fetch or refetch on mount. Which is pretty much what happens on web. But if I navigate back they will not refetch since it's not a new mount. That's where the useFocusEffect from React Navigation can come in and handle those cases.

Did you find this page helpful?