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

If revalidateOnFocus and suspense are used together, when an error occurs onfoucs listeners are never cleaned up #1093

Closed
gaoxiaoliangz opened this issue Apr 3, 2021 · 2 comments · Fixed by #2658
Labels
area: suspense discussion Discussion around current or proposed behavior

Comments

@gaoxiaoliangz
Copy link

Bug report

Description / Observed Behavior

If revalidateOnFocus and suspense are used together, when an error occurs onfoucs listeners are never cleaned up

Expected Behavior

When errors are caught in error boundary, onfocus listeners are cleaned up, a page refocus never triggers a revalidation.

Additional Context

SWR version: 0.5.5

@promer94
Copy link
Collaborator

promer94 commented Apr 3, 2021

Hi, could you please provide a codesandbox repro ?

FYI: https://codesandbox.io/s/suspense-focus-5c0zf?file=/src/App.js
This seems works

@shuding shuding added discussion Discussion around current or proposed behavior area: suspense and removed reproduction needed labels Oct 1, 2021
@shuding
Copy link
Member

shuding commented Oct 1, 2021

I think this is tricky – when a component throws and gets caught by the error boundary, the hooks will be unmounted so you can't re-render anymore. The same applies to a Suspense boundary as well.

This needs more discussion, also related to #168.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: suspense discussion Discussion around current or proposed behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants