Skip to content

SWR v0.4.1 crashes React Native when debugging #953

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

Closed
mikevercoelen opened this issue Feb 3, 2021 · 4 comments · Fixed by #963
Closed

SWR v0.4.1 crashes React Native when debugging #953

mikevercoelen opened this issue Feb 3, 2021 · 4 comments · Fixed by #963

Comments

@mikevercoelen
Copy link

mikevercoelen commented Feb 3, 2021

When debugging React Native, SWR v0.4.1 is causing the following error:

document is not defined

It's due to all changes where we use document without checking if it exists:

0.4.0...0.4.1

if (!IS_SERVER && window.addEventListener) {

// ...

window.addEventListener(

Became this:

if (!IS_SERVER && window.addEventListener && document.addEventListener) {

// ...

document.addEventListener(

V0.4.0 is working fine

@mikevercoelen mikevercoelen changed the title SWR v0.4.1 throws error on react native SWR v0.4.1 crashes React Native when debugging Feb 3, 2021
@koba04
Copy link
Collaborator

koba04 commented Feb 4, 2021

I've created a PR to fix this. #963

@mikevercoelen
Copy link
Author

Can we get a release for this please? As the latest version is broken on React Native, pretty essential to get this out there asap?

@koba04
Copy link
Collaborator

koba04 commented Feb 8, 2021

@mikevercoelen That makes sense for me.
@shuding Could you publish a new version?

@shuding
Copy link
Member

shuding commented Feb 8, 2021

Sorry for the delay, just published version 0.4.2 🙏

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 a pull request may close this issue.

3 participants