Skip to content

fix: checking if document is defined #963

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
merged 1 commit into from
Feb 4, 2021

Conversation

koba04
Copy link
Collaborator

@koba04 koba04 commented Feb 4, 2021

Fixes #953.
This seems to be caused by the change of #889.
I've added the check if document is defined before SWR uses document.addEventListener.

The check is already being used at

typeof document !== 'undefined' &&

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 4, 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 c509234:

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

@koba04
Copy link
Collaborator Author

koba04 commented Feb 4, 2021

If SWR wants to support focus and online events on ReactNative, I should the the if statement only applies to the visibilitychange event.

@shuding shuding merged commit d55853f into vercel:master Feb 4, 2021
@shuding
Copy link
Member

shuding commented Feb 4, 2021

Thanks! I'm thinking about moving all the platform specific things into "presets", so they can be imported conditionally.

@koba04 koba04 deleted the fix-document-on-react-native branch February 4, 2021 15:14
@koba04
Copy link
Collaborator Author

koba04 commented Feb 4, 2021

Thank you! I agree with you 👍

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.

SWR v0.4.1 crashes React Native when debugging
2 participants