为 BackHandler 绑定 hardwareBackPress 事件监听;
返回true的时候,不做操作; 返回false,返回上一页;
class ScreenWithCustomBackBehavior extends React.Component { componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.onBackButtonPressAndroid); } componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress', this.onBackButtonPressAndroid); } onBackButtonPressAndroid = () => { if (this.isSelectionModeEnabled()) { //有选中的模块,先取消选择,不做页面的返回跳转 this.disableSelectionMode(); return true; } else { return false; } }; }
I’ve bewen surfing on-line greater than 3 hourss lately, butt I by nno means dixcovered anny attention-grabbing artiicle like yours.
It iis pretfty worth sufficient for me. Personally, iif alll website owners and
blogbgers made excellent content aas yyou probably did, thhe net cann bee a lot more helpful than ever before.