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

Improvement: return stale data then revalidate when setting size of useSWRInfinite #1343

Merged
merged 3 commits into from
Aug 16, 2021

Conversation

shuding
Copy link
Member

@shuding shuding commented Aug 14, 2021

Right now useSWRInfinite directly revalidates after changing its page size. If that revalidation awaits due to some reason, you can't immediately get the new resized page array even if everything is already in the cache.

This PR changes the behavior to use mutate to first return the stale page array with the updated size, and then revalidate in the background.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 14, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f0f0520:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

@shuding shuding marked this pull request as ready for review August 15, 2021 17:46
@shuding shuding requested a review from huozhi as a code owner August 15, 2021 17:46
@shuding shuding merged commit 20ace5a into master Aug 16, 2021
@shuding shuding deleted the improve-infinite-cache branch August 16, 2021 16:31
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

Successfully merging this pull request may close these issues.

2 participants