Skip to content

useSWR with Suspense remains in loading state when response data is identical #1083

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

Closed
damusnet opened this issue Mar 29, 2021 · 2 comments
Closed

Comments

@damusnet
Copy link

Bug report

Description / Observed Behavior

When using suspense mode, if two API calls with different urls return the same data, the component remains in a loading state.

Expected Behavior

The component should update to reflect the new data, even if it's identical to the previous data.

Repro Steps / Code Example

https://codesandbox.io/s/recursing-williams-lsh4m?file=/pages/index.js

Click the button. It changes the url, but the data returned is always the same, since it's a static function.
Component remains in loading state, instead of displaying the new url.
See also the incrementing counter in the console for the new url, indicating that useSWR keeps re-fetching the data.

Kapture.2021-03-29.at.14.56.04.mp4

You can toggle lines 29 and 34 and see that a different API response triggers a render, whereas the same response remains in loading.

You can toggle line 22 and see that without suspense things work fine, but as soon as suspense is on, it keeps loading forever when the response is the same.

Additional Context

I was under the impression that this worked before v0.5 but changing the version on CodeSanbox yields the same result, so I'm not so sure anymore

@promer94
Copy link
Collaborator

Thanks for your detailed repro.
This bug is a duplicate of #1056.
It has been fixed in #1058

@damusnet
Copy link
Author

Oh, great, thanks!
Sorry for the duplicate, I only looked through the open issues 😅

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