这在大多数情况下应该有效:
componentWillReceiveProps(nextProps) { if ( nextProps.token == undefined || _.isNil(nextProps.token) ) { let action = NavigationActions.reset({ index: 0, key: null, actions: [ NavigationActions.navigate({routeName: 'Auth'}) ] }); nextProps.navigation.dispatch(action); } ...}或尝试通过自定义操作增强导航器:
const changeAppNavigator = Navigator => { const router = Navigator.router; const defaultGetStateForAction = router.getStateForAction; router.getStateForAction = (action, state) => { if (state && action.type === "RESET_TO_AUTH") { let payLoad = { index: 0, key: null, actions: [NavigationActions.navigate({routeName: "AuthStackNavigator"})] }; return defaultGetStateForAction(NavigationActions.reset(payLoad), state); // or this might work for you, not sure: // return defaultGetStateForAction(NavigationActions.init(), state) } return defaultGetStateForAction(action, state); }; return Navigator;};const screens = { ... }RootTabNavigator = changeAppNavigator(TabNavigator(screens, { initialRouteName: ..., ...}));然后在你
Menuo Screen做:
componentWillReceiveProps(nextProps) { if ( nextProps.token == undefined || _.isNil(nextProps.token) ) { nextProps.navigation.dispatch({type: "RESET_TO_AUTH"}); ...


