react-native - 检测在导航器之间移动的导航动作
问题描述
这就是我的导航器的定义方式:
const navigatorA = TabNavigator({
screenA :{screen: navigatorX},
screenB: {screen: navigatorY},
});
const navigatorX = Stacknavigator({
home: {screen: home},
options: {screen: options},
});
const navigatorY = StackNavigator({
profile: {screen: profile},
settings :{ screen: settings}
})
我通过参数喜欢this.props.navigation.navigate({routeName:'profile', params:{user:{thisUser}});
当用户从配置文件屏幕导航回主屏幕时,我想重置导航参数,而不是当用户从配置文件屏幕导航到设置屏幕时。
使用this.props.navigation.setParams({user:nulll});
incomponenWillUnmount
无法完成任务,因为即使用户从配置文件导航到设置,它也会重置参数。
我也尝试过使用willBlur
事件侦听器,但它不适用于堆栈导航器,只能在选项卡导航器中使用。
解决方案
推荐阅读
- html - 如何对齐图片下方的简短文字?
- javascript - 为什么我会不确定?(JS)
- javascript - 为什么我不能在调用提示函数之前修改 DOM?
- java - for循环内的Java Rate Limiter,在获取调用外部api(具有节流)后不限制速率
- python - Keras 在自定义随机 AF 时报告“ValueError: initial_value must have a shape specified:Tensor("dense_4/MatMul:0",shape=(?, 1),dtype=float32)"
- reactjs - CRA PWA Service Worker 不刷新
- javascript - 如何隐藏画布元素?
- javascript - HTML 模板未在屏幕上呈现
- r - R - 平滑散点图曲线和对角轴
- linux - 我正在尝试在 bash 中使用 mlocate 和 for 循环来搜索大量文件