You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a screen with a few layers of nested components. Some of these components make their own calls to useSWRNative to get data that is needed, but they are all using the same cache key. Normally this is totally fine as SWR will load the data once and then share it with all components that requested it.
useSWRNative triggers a revalidate on a focus event if enough time has passed since the previous focus event. This logic appears to be flawed since the lastFocusedAt ref is per hook, not per cache key.
This results in many requests being made when we focus a screen that makes use of multiple useSWRNative calls with the same cache key. (one call for each usage of the hook).
Note: I pulled in the changes in this PR and found that the issue is resolved when using useSWR (instead of useSWRNative) but having the still having this library used in the middleware to revalidate on focus events.
The text was updated successfully, but these errors were encountered:
From what I tested at that time, using useSWR hook (not useSWRNative) in combination with the swr-react-native middleware in the PR mentioned above we were not getting multiple calls for the same cache key on refocus of the screen.
We have a screen with a few layers of nested components. Some of these components make their own calls to
useSWRNative
to get data that is needed, but they are all using the same cache key. Normally this is totally fine as SWR will load the data once and then share it with all components that requested it.useSWRNative
triggers a revalidate on a focus event if enough time has passed since the previous focus event. This logic appears to be flawed since thelastFocusedAt
ref is per hook, not per cache key.This results in many requests being made when we focus a screen that makes use of multiple
useSWRNative
calls with the same cache key. (one call for each usage of the hook).Note: I pulled in the changes in this PR and found that the issue is resolved when using
useSWR
(instead ofuseSWRNative
) but having the still having this library used in the middleware to revalidate on focus events.The text was updated successfully, but these errors were encountered: