覆盖此功能,它将返回上一页,但同时将退出该应用程序。只需按一次返回按钮,

时间:2018-07-18 13:50:16

标签: javascript reactjs react-native react-router react-redux

class App extends React.Component {
  constructor(props) {
    super(props);
    this.onGoBack = this.onGoBack.bind(this);
  }

  componentDidMount() {
    BackHandler.addEventListener("hardwareBackPress", this.onGoBack);
  }

  componentWillUnmount() {
    BackHandler.removeEventListener("hardwareBackPress", this.onGoBack);
  }

  onGoBack = () => {
    Alert.alert("jiifwff");

    console.log("ahbjhavf");

    ToastAndroid.show("Back button is pressed", ToastAndroid.SHORT);

    return true;
  };
}

0 个答案:

没有答案