mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 03:50:11 +08:00
Move BackAndroid -> BackHandler, add Apple TV support for back nav
Summary: Enable back navigation on Apple TV (with the remote's menu button) in code making use of BackAndroid. The module is renamed to BackHandler. BackAndroid is still exported to ReactNative for now, until external projects switch to using the new name for the module. The navigation in https://github.com/react-community/react-navigation makes use of this module. **Test plan**: Manual testing with an example app (https://github.com/dlowder-salesforce/react-nav-example). Closes https://github.com/facebook/react-native/pull/12571 Differential Revision: D4665152 Pulled By: ericvicenti fbshipit-source-id: 925400ce216379267e014457be6f5eedbe4453ec
This commit is contained in:
committed by
Facebook Github Bot
parent
9325496d46
commit
b7e9374c64
@@ -25,7 +25,7 @@
|
||||
|
||||
const AppRegistry = require('AppRegistry');
|
||||
const AsyncStorage = require('AsyncStorage');
|
||||
const BackAndroid = require('BackAndroid');
|
||||
const BackHandler = require('BackHandler');
|
||||
const Dimensions = require('Dimensions');
|
||||
const DrawerLayoutAndroid = require('DrawerLayoutAndroid');
|
||||
const Linking = require('Linking');
|
||||
@@ -73,7 +73,7 @@ class UIExplorerApp extends React.Component {
|
||||
state: UIExplorerNavigationState;
|
||||
|
||||
componentWillMount() {
|
||||
BackAndroid.addEventListener('hardwareBackPress', this._handleBackButtonPress);
|
||||
BackHandler.addEventListener('hardwareBackPress', this._handleBackButtonPress);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
'use strict';
|
||||
|
||||
const AsyncStorage = require('AsyncStorage');
|
||||
const BackHandler = require('BackHandler');
|
||||
const Linking = require('Linking');
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
@@ -68,6 +69,10 @@ class UIExplorerApp extends React.Component {
|
||||
props: Props;
|
||||
state: UIExplorerNavigationState;
|
||||
|
||||
componentWillMount() {
|
||||
BackHandler.addEventListener('hardwareBackPress', this._handleBack);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
Linking.getInitialURL().then((url) => {
|
||||
AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => {
|
||||
|
||||
Reference in New Issue
Block a user