mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Remove BackAndroid, which has had a deprecation warning (#21866)
Summary: Remove BackAndroid, which has had a deprecation warning and only forwarded to BackHandler since March 2018. Test Plan --------- React-native init bundle and RNTester bundle works. Release Notes: -------------- [ ANDROID ] [ BREAKING ] [ BackAndroid ] - Deprecate BackAndroid since BackHandler should be used in its place. Pull Request resolved: https://github.com/facebook/react-native/pull/21866 Differential Revision: D10472419 Pulled By: TheSavior fbshipit-source-id: 3d76e1ce4c74bb783fee7fd8232bb366f2e7ea12
This commit is contained in:
committed by
Facebook Github Bot
parent
6b0e924915
commit
774cd73663
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* BackAndroid has been moved to BackHandler. This stub calls BackHandler methods
|
||||
* after generating a warning to remind users to move to the new BackHandler module.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const BackHandler = require('BackHandler');
|
||||
|
||||
const warning = require('fbjs/lib/warning');
|
||||
|
||||
/**
|
||||
* Deprecated. Use BackHandler instead.
|
||||
*/
|
||||
const BackAndroid = {
|
||||
exitApp: function() {
|
||||
warning(
|
||||
false,
|
||||
'BackAndroid is deprecated. Please use BackHandler instead.',
|
||||
);
|
||||
BackHandler.exitApp();
|
||||
},
|
||||
|
||||
addEventListener: function(
|
||||
eventName: BackPressEventName,
|
||||
handler: Function,
|
||||
): {remove: () => void} {
|
||||
warning(
|
||||
false,
|
||||
'BackAndroid is deprecated. Please use BackHandler instead.',
|
||||
);
|
||||
return BackHandler.addEventListener(eventName, handler);
|
||||
},
|
||||
|
||||
removeEventListener: function(
|
||||
eventName: BackPressEventName,
|
||||
handler: Function,
|
||||
): void {
|
||||
warning(
|
||||
false,
|
||||
'BackAndroid is deprecated. Please use BackHandler instead.',
|
||||
);
|
||||
BackHandler.removeEventListener(eventName, handler);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = BackAndroid;
|
||||
@@ -195,9 +195,6 @@ module.exports = {
|
||||
get AsyncStorage() {
|
||||
return require('AsyncStorage');
|
||||
},
|
||||
get BackAndroid() {
|
||||
return require('BackAndroid');
|
||||
}, // deprecated: use BackHandler instead
|
||||
get BackHandler() {
|
||||
return require('BackHandler');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user