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

Unexpected revalidateIfStale = false initial load behavior on key change #2930

Open
sheern opened this issue Apr 4, 2024 · 1 comment
Open

Comments

@sheern
Copy link

sheern commented Apr 4, 2024

Bug report

Description / Observed Behavior

In my usage of the useSWRImmutable hook, my component has a dynamic key as state. Upon an update to this key, I expected an immediate isLoading == true (assuming that the key is brand new) as there's no cached data associated with it. Instead, there's a split second where isLoading is false before loading as normal. I've narrowed this down to the revalidateIfStale option.

Expected Behavior

When revalidateIfStale is false, the first time a key is encountered should immediately set isLoading to true as there's no stale data.

Repro Steps / Code Example

Here's a CodeSandbox of the issue. You can see the unexpected state logged in the console.

@0xrelapse
Copy link

Also seeing this exact issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants