Android-Handle Back Button
文章目录

Below Codes Requires Confirmation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import {
BackHandler,
} from 'react-native';

class SearchScreen extends React.Component {

componentDidMount() {
this.backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
/* do something */
this.props.search_reset_category();

return true;
});
}

componentWillUnmount() {
this.backHandler.remove();
}

render(){
/*...*/
}
}