react-native-router-flux addListener 不起作用
react-native-router-flux addListener doesn't work
我正在使用
本机反应": "0.62.2",
react-native-router-flux: "4.2.0-beta.1",
addListener 不起作用,并且 console.log 从不调用
componentDidMount() {
this.props.navigation.addListener(ActionConst.RESET, () => {
console.log('RESET');
});
this.props.navigation.addListener(ActionConst.FOCUS, () => {
console.log('FOCUS');
});
this.props.navigation.addListener(ActionConst.PUSH, () => {
console.log('PUSH');
});
this.props.navigation.addListener(ActionConst.POP_TO, () => {
console.log('POP_TO');
});
}
有没有我可以查看的方法或文档?
你只有
- willFocus - 屏幕将聚焦
- didFocus - 屏幕聚焦(如果有转换,则转换完成)
- willBlur - 屏幕将不聚焦
- didBlur - 屏幕未聚焦(如果有过渡,则过渡完成)
添加监听器
componentDidMount(){
const didBlurSubscription = this.props.navigation.addListener(
'didBlur',() => {
console.log('didBlur');
}
);
}
componentWillUnmount(){
// Remove the listener when you are done
didBlurSubscription.remove();
}
我正在使用
本机反应": "0.62.2", react-native-router-flux: "4.2.0-beta.1",
addListener 不起作用,并且 console.log 从不调用
componentDidMount() {
this.props.navigation.addListener(ActionConst.RESET, () => {
console.log('RESET');
});
this.props.navigation.addListener(ActionConst.FOCUS, () => {
console.log('FOCUS');
});
this.props.navigation.addListener(ActionConst.PUSH, () => {
console.log('PUSH');
});
this.props.navigation.addListener(ActionConst.POP_TO, () => {
console.log('POP_TO');
});
}
有没有我可以查看的方法或文档?
你只有
- willFocus - 屏幕将聚焦
- didFocus - 屏幕聚焦(如果有转换,则转换完成)
- willBlur - 屏幕将不聚焦
- didBlur - 屏幕未聚焦(如果有过渡,则过渡完成)
添加监听器
componentDidMount(){
const didBlurSubscription = this.props.navigation.addListener(
'didBlur',() => {
console.log('didBlur');
}
);
}
componentWillUnmount(){
// Remove the listener when you are done
didBlurSubscription.remove();
}