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

How to manually refresh infinite data? #1597

Closed
hazae41 opened this issue Oct 27, 2021 · 1 comment
Closed

How to manually refresh infinite data? #1597

hazae41 opened this issue Oct 27, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@hazae41
Copy link

hazae41 commented Oct 27, 2021

Bug report

Description / Observed Behavior

For a long time I used mutate() to refresh infinite data

const res = useSWRInfinite(key)
const refresh = () => res.mutate()

But recently this caused some bugs as the behaviour of swr changed (mutate() becomes mutate(undefined))

So I am now using:

const res = useSWRInfinite(key)
const refresh = () => res.mutate(d => d)

The problem is that this technique doesn't work with revalidateFirstPage: false:
mutate(d => d) does nothing when using revalidateFirstPage: false

Is this an issue? Do I use the good way of mutating infinite data?

Additional Context

swr@1.0.0-beta.6

@shuding shuding added the bug Something isn't working label Oct 29, 2021
@shuding
Copy link
Member

shuding commented Oct 29, 2021

By design, mutate() should work but because of the bug you have to use mutate(d => d).

mutate(d => d) does nothing when using revalidateFirstPage: false

This seems to be another bug, thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants