NoriginMedia / react-spatial-navigation

DEPRECATED. HOC-based Spatial Navigation. NEW Hooks version is available here: https://github.com/NoriginMedia/norigin-spatial-navigation
MIT License
226 stars 64 forks source link

fix(RN): Check for both window and window.add/removeEventListener #50

Closed shirakaba closed 4 years ago

shirakaba commented 4 years ago

The React Native debugger, which uses the Chrome browser's V8 JS runtime rather than the mobile device's own JS runtime, introduces the window object. This means that when debugging a React Native app, we unintentionally pass the bindEventHandlers or unbindEventHandlers conditional check and throw an error upon attempting to call window.addEventListener or window.removeEventListener (except on React Native Web), as these methods are only implemented in web browser environments.

By checking explicitly for both window and window.addEventListener/window.removeEventListener, we safely fail this conditional check on React Native non-web targets while the Chrome debugger is attached.

asgvard commented 4 years ago

Thanks! We are just back from vacations and will start reviewing PRs and cleaning up soon :)

asgvard commented 4 years ago

Finally got some time to review all of the PRs :) sorry for a long silence