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

fix: mutate args for useSWRInfinite hook #1947

Merged
merged 8 commits into from May 14, 2022

Conversation

sanjeev29
Copy link
Contributor

This PR fixes the bug mentioned in #1899.

As mentioned in the documentation (https://swr.vercel.app/docs/pagination#return-values), mutate function returned by the useSWRInfinite hook should work the same as the useSWR hook.

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 1, 2022

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 656691d:

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

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! Would you mind adding a test so we won't have regression in the future?

@sanjeev29
Copy link
Contributor Author

@shuding Yes! Will do that.

@sanjeev29 sanjeev29 force-pushed the fix/swr-infinite-mutate-args branch from 1216358 to b6f4781 Compare May 1, 2022 13:02
@koba04
Copy link
Collaborator

koba04 commented May 2, 2022

@shuding
Should the mutate function useSWRInfinite returns support the following options as well as the revalidate option?

  • optimisticData
  • populateCache
  • rollbackOnError

https://swr.vercel.app/docs/mutation#optimistic-updates

If not, it would be nice to add the supported options to the documentation.

@sanjeev29
Copy link
Contributor Author

@koba04 @shuding
Right now it only accepts revalidate option. I can actually update it to accept other options too.

@shuding
Copy link
Member

shuding commented May 2, 2022

Yes, I think these should be supported by this hook too! But in the meantime it might take some time to get them implemented, so we can have separate follow up PRs.

@sanjeev29 sanjeev29 force-pushed the fix/swr-infinite-mutate-args branch from 2d7078f to b6f4781 Compare May 2, 2022 22:25
@koba04
Copy link
Collaborator

koba04 commented May 14, 2022

The following type also should be updated, but I think it's ok to fix it with the following PR

boolean

@sanjeev29
Copy link
Contributor Author

@koba04 I can resolve these conflicts?

@shuding shuding merged commit d81aa78 into vercel:main May 14, 2022
@shuding
Copy link
Member

shuding commented May 14, 2022

Thanks!

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.

None yet

3 participants