Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

How Do I handle Hardware back button of android to screen which I given to navigation.navigate in react native

I am new to react native. I want that when I press android Hardware back button. I navigate to page or screen which name I have given To that navigation.navigate

I have made this

constructor(props) {
    super(props)
    this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
}

componentDidMount() {
    BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
}

componentDidUnmount() {
    BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
}

handleBackButtonClick() {
    this.props.navigation.navigate("Browse");
    return true;
}

But using this code Its only navigate to previous screen from which I have come. I want to navigate to "browse" screen. please help. thanks

question from:https://stackoverflow.com/questions/66061426/how-do-i-handle-hardware-back-button-of-android-to-screen-which-i-given-to-navig

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...