如何使用 NavigationAction 调用操作???
如果用户没有令牌,则会返回初始页面。我想重置(初始化)MainTabNavigator
.
componentWillReceiveProps(nextProps) {
if ( nextProps.token == undefined || _.isNil(nextProps.token) ) {
const backAction = NavigationActions.back({
key: null
})
nextProps.navigation.dispatch(backAction);
这是 MainTabNavigator。我添加了在触发“MyCompleteReset”时重置所有内容的路线。
export default TabNavigator({ ........ });
const navigator = MainTabNavigator;
const defaultGetStateForAction = navigator.router.getStateForAction
navigator.router.getStateForAction = (action, state) => {
if (action.type === 'MyCompleteReset') {
// For your custom action, reset it all
return defaultGetStateForAction(NavigationActions.init())
}
// Handle all other actions with the default handler
return defaultGetStateForAction(action, state)
}
我们如何称呼MyCopmleteReset
行动???
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)