mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-30 23:22:41 +08:00
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
29 lines
627 B
JavaScript
29 lines
627 B
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* iOS stub for BackAndroid.android.js
|
|
*
|
|
* @providesModule BackAndroid
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
function emptyFunction() {}
|
|
|
|
const BackAndroid = {
|
|
exitApp: emptyFunction,
|
|
addEventListener() {
|
|
return {
|
|
remove: emptyFunction,
|
|
};
|
|
},
|
|
removeEventListener: emptyFunction,
|
|
};
|
|
|
|
module.exports = BackAndroid;
|