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

Use the initCache function for the cache to be passed to the provider in SWRConfig. #550

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

naporin0624
Copy link

@naporin0624 naporin0624 commented Nov 4, 2023

Description

Thank you for developing this wonderful library. I found some changes in the documentation that would make it even better!

  • The provider passed to SWRConfig has been changed to one using initCache.
  • Added to the documentation to use the return value of initCache instead of using global mutate.

swr's defaultCache is created using initCache and swr's global mutate references it. https://github.com/vercel/swr/blob/main/_internal/src/utils/config.ts#L43-L45

There have been a few issues about SWRConfig not working when using global mutate after changing the provider in SWRConfig, and this would solve that problem.

vercel/swr#2799

  • Adding new page
  • Updating existing documentation
  • Other updates

Example

https://codesandbox.io/s/swr-initcache-ltfwn6?file=/src/App.tsx

Copy link

vercel bot commented Nov 4, 2023

@naporin0624 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant