Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit 7859190

Browse files
authored
fix(React Native): Check for both window and window.addEventListener or window.removeEventListener. (#50)
1 parent 31f1101 commit 7859190

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/spatialNavigation.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ class SpatialNavigation {
385385
}
386386

387387
bindEventHandlers() {
388-
if (window) {
388+
// We check both because the React Native remote debugger implements window, but not window.addEventListener.
389+
if (window && window.addEventListener) {
389390
this.keyDownEventListener = (event) => {
390391
if (this.paused === true) {
391392
return;
@@ -449,7 +450,8 @@ class SpatialNavigation {
449450
}
450451

451452
unbindEventHandlers() {
452-
if (window) {
453+
// We check both because the React Native remote debugger implements window, but not window.removeEventListener.
454+
if (window && window.removeEventListener) {
453455
window.removeEventListener('keydown', this.keyDownEventListener);
454456
this.keyDownEventListener = null;
455457

0 commit comments

Comments
 (0)