Skip to content

Commit

Permalink
fixed polyfill for BackAndroid
Browse files Browse the repository at this point in the history
Summary:
`BackAndroid.addEventListener()` returns a subscription object with a `remove()` function in android. Before this fix, the iOS equivalent doesn't return anything, which means, if there's a component doing something like this, it would redbox:

```
componentWillMount() {
  this._subscription = BackAndroid.addEventListener('hardwareBackPress', () => {...});
}

componentWillUnmount() {
  this._subscription.remove(); // --> redbox in iOS before this fix
}
```

Differential Revision: D3790480

fbshipit-source-id: 1e607171bf2892a6b64977c4fd052c5df0bc4a0d
  • Loading branch information
fkgozali authored and Facebook Github Bot 6 committed Aug 30, 2016
1 parent 0a1d728 commit 150fe7c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Libraries/Utilities/BackAndroid.ios.js
Expand Up @@ -17,7 +17,11 @@ function emptyFunction() {}

const BackAndroid = {
exitApp: emptyFunction,
addEventListener: emptyFunction,
addEventListener() {
return {
remove: emptyFunction,
};
},
removeEventListener: emptyFunction,
};

Expand Down

0 comments on commit 150fe7c

Please sign in to comment.