Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stale data with fallbackData, keepPreviousData and disabled revalidation #2128

Closed
alexanbj opened this issue Aug 19, 2022 · 1 comment · Fixed by #2169
Closed

Stale data with fallbackData, keepPreviousData and disabled revalidation #2128

alexanbj opened this issue Aug 19, 2022 · 1 comment · Fixed by #2169

Comments

@alexanbj
Copy link

Bug report

Description / Observed Behavior

This bug occurs when using the new keepPreviousData option (in v2 beta) together with fallbackData and disabling the automatic revalidation features. The first time you switch back to the "initial key" the returned data doesn't update. It belongs to the previous key.

Subsequent key changes back to the initial key works fine. Note that this only happens when disabling revalidation When using the default revalidation settings this doesn't occur at all.

Expected Behavior

See reproduction.

My use case here is that I don't want to refetch the data on the client when mounting. The fallbackData is fresh/retrieved during SSR.

Repro Steps / Code Example

Check the checkbox and the data filters, uncheck the checkbox and the data is stale. Further toggling/key changes works as expected.

https://codesandbox.io/s/exciting-agnesi-e704i2?file=/src/App.js

Additional Context

SWR version: 2.0.0-beta.6

koba04 added a commit to koba04/swr that referenced this issue Sep 22, 2022
koba04 added a commit to koba04/swr that referenced this issue Sep 23, 2022
koba04 added a commit to koba04/swr that referenced this issue Sep 23, 2022
…epPreviousData is enabled

test: add a failed test for vercel#2128
koba04 added a commit to koba04/swr that referenced this issue Sep 23, 2022
…epPreviousData is enabled

test: add a failed test for vercel#2128
@koba04
Copy link
Collaborator

koba04 commented Sep 23, 2022

@alexanbj Thank you for your feedback! I've created a PR to fix this. #2169

huozhi pushed a commit that referenced this issue Oct 4, 2022
…epPreviousData is enabled (#2169)

test: add a failed test for #2128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants