Skip to content

test: add a test for useSWRInfinite with initialData #894

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

Merged

Conversation

koba04
Copy link
Collaborator

@koba04 koba04 commented Jan 12, 2021

This PR adds a test for useSWRInfinite with initialData.

I've added the test, but I'm still not sure of the expected behavior in the case.

How should useSWRInfinite behave combined with initialData?

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 12, 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 aec19dd:

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

@koba04 koba04 force-pushed the add-test-for-swrInfinite-with-initial-data branch from becb69b to cba990c Compare January 12, 2021 15:17
Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is the expected behavior. useSWRInfinite should reuse initialData just like useSWR does because it's technically a wrapper of useSWR.

@shuding
Copy link
Member

shuding commented Jan 13, 2021

And for the question:

Is the initialData stored in the cache store?

Nope, initialData is considered as a fallback value of data, it won't be pre-filled into the cache.

@shuding shuding merged commit 6a07522 into vercel:master Jan 13, 2021
@koba04
Copy link
Collaborator Author

koba04 commented Jan 14, 2021

Thank you!

@koba04 koba04 deleted the add-test-for-swrInfinite-with-initial-data branch January 14, 2021 01:11
@shunkakinoki
Copy link

shunkakinoki commented Mar 4, 2022

hi guys! if I want to pull initialData into from thefallback key of SwrConfig in the page root what is the correct key to put in it? useSWRInfinite seems to have a special $inf$, attached to it.

https://swr.vercel.app/docs/with-nextjs

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.

3 participants