#useFocusNotifyOnChangeProps is not fresh after re-focus

2 messages · Page 1 of 1 (latest)

candid hare
#

Hello!

In react native I have a screen where I load data with react-query. When it's out of focus I would like to not refresh the data.
I checked the useFocusNotifyOnChangeProps as docs said, it works well but something is missing.

When I return to the screen which was out of focus, there is the old state visible. It's not re-render at re-focus.

Steps:
Screen 1: Fetch data with RQ
Screen 1: Go to screen 2,

Screen 2: reload the same query
Screen 2: Go back to screen 1

Screen 1: Rendered data not fresh!

Is it possible to refresh data in the screen without call refetch?

Thank you!

#

Docs said: "This custom hook provides a notifyOnChangeProps option that will return an empty array whenever a screen goes out of focus - effectively stopping any re-renders on that scenario. Whenever the screens gets in focus again, the behavior goes back to normal."

It goes back to normal but I would like to show the last data from react-query cache.