[fix] Reintroduce BackHandler with console.error

This API will be removed in a future version.
This commit is contained in:
Nicolas Gallagher
2023-04-05 10:15:23 -07:00
parent 985c79f924
commit 1c5119b7e1
3 changed files with 28 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ module.exports = {
AppRegistry: true,
AppState: true,
Appearance: true,
BackHandler: true,
Button: true,
CheckBox: true,
Clipboard: true,

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
function emptyFunction() {}
const BackHandler = {
exitApp: emptyFunction,
addEventListener(): {| remove: () => void |} {
console.error(
'BackHandler is not supported on web and should not be used.'
);
return {
remove: emptyFunction
};
},
removeEventListener: emptyFunction
};
export default BackHandler;

View File

@@ -13,6 +13,7 @@ export { default as Animated } from './exports/Animated';
export { default as Appearance } from './exports/Appearance';
export { default as AppRegistry } from './exports/AppRegistry';
export { default as AppState } from './exports/AppState';
export { default as BackHandler } from './exports/BackHandler';
export { default as Clipboard } from './exports/Clipboard';
export { default as Dimensions } from './exports/Dimensions';
export { default as Easing } from './exports/Easing';