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

First page of useSWRInfinite should reuse the cache from useSWR #799

Merged
merged 2 commits into from
Jan 7, 2021

Conversation

shuding
Copy link
Member

@shuding shuding commented Dec 8, 2020

Currently useSWRInfinite always refetches the first page because of this line:

(typeof force === 'undefined' && i === 0)

and it will not reuse the cache from useSWR. This PR fixes that so if there is no originalData (the first render), but has pageData (has cache), we directly return the cache.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 8, 2020

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 01a2879:

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

@shuding shuding requested a review from huozhi January 6, 2021 15:39
@shuding shuding merged commit 62d5cfa into master Jan 7, 2021
@shuding shuding deleted the reuse-cache branch January 7, 2021 16:43
@shuding
Copy link
Member Author

shuding commented Jan 7, 2021

Thanks @huozhi!

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