Skip to content

Commit 1c5119b

Browse files
committed
[fix] Reintroduce BackHandler with console.error
This API will be removed in a future version.
1 parent 985c79f commit 1c5119b

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

packages/babel-plugin-react-native-web/src/moduleMap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
AppRegistry: true,
88
AppState: true,
99
Appearance: true,
10+
BackHandler: true,
1011
Button: true,
1112
CheckBox: true,
1213
Clipboard: true,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright (c) Nicolas Gallagher.
3+
* Copyright (c) Meta Platforms, Inc. and affiliates.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*
8+
* @flow
9+
*/
10+
11+
function emptyFunction() {}
12+
13+
const BackHandler = {
14+
exitApp: emptyFunction,
15+
addEventListener(): {| remove: () => void |} {
16+
console.error(
17+
'BackHandler is not supported on web and should not be used.'
18+
);
19+
return {
20+
remove: emptyFunction
21+
};
22+
},
23+
removeEventListener: emptyFunction
24+
};
25+
26+
export default BackHandler;

packages/react-native-web/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export { default as Animated } from './exports/Animated';
1313
export { default as Appearance } from './exports/Appearance';
1414
export { default as AppRegistry } from './exports/AppRegistry';
1515
export { default as AppState } from './exports/AppState';
16+
export { default as BackHandler } from './exports/BackHandler';
1617
export { default as Clipboard } from './exports/Clipboard';
1718
export { default as Dimensions } from './exports/Dimensions';
1819
export { default as Easing } from './exports/Easing';

0 commit comments

Comments
 (0)