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: Make SWR compatible with React Native again (window.addEventListener.bind fails) #1234

Merged
merged 1 commit into from
Jun 23, 2021

Conversation

javascripter
Copy link
Contributor

In React Native environments, window refers to global object but window.addEventListener does not exit, so we need to check window.addEventListener exists too in addition to window existence to allow running in React Native environments.

ref. https://stackoverflow.com/questions/49911424/what-does-the-variable-window-represent-in-react-native

This incompatibility with RN was accidentally introduced in this PR.
b38d1bd#diff-8e1a842791533fc5b3bd3a489a491864e056b3ddd867b208e566d05319175860L27

@codesandbox-ci
Copy link

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 24c8581:

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

@javascripter javascripter changed the title Fix: Make SWR compatible with React Native (window.addEventListener.bind fails) Fix: Make SWR compatible with React Native again (window.addEventListener.bind fails) Jun 23, 2021
Copy link
Member

@huozhi huozhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@huozhi huozhi merged commit f84c886 into vercel:master Jun 23, 2021
@javascripter javascripter deleted the fix-web-preset-for-react-native branch June 23, 2021 12:01
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

2 participants