React Navigation不会为模态传递参数

时间:2019-04-09 19:39:55

标签: typescript react-native react-navigation

我有3层StackNavigator

第一层

const RootNavigator = createStackNavigator(
  {
    Main: MainNavigator,
    [Screens.Result]: ResultModal,
  },
  {
    mode: 'modal',
    headerMode: 'none',
    transparentCard: true,
    initialRouteName: 'Main',
  },

第二层

const MainNavigator = createStackNavigator(
  {
    [Screens.Landing]: LandingScreen,
    Feature: FeatureNavigator,
  },
  {
    mode: 'card',
    headerMode: 'none',
    initialRouteName: Screens.Landing,
  },
)

第三层

const FeatureNavigator = createStackNavigator(
  {
    [Screens.Payout]: PayoutScreen,
  },
  {
    mode: 'card',
    initialRouteName: Screens.Payout,
  },
)

PayoutScreen中有

this.props.navigation.navigate('Result', {test: '123'}

然后,当我监视Reactotron中的导航道具时,navigation.state.params等于undefined。奇怪的是,我使用相同的方法将参数从LandingScreen传递到PayoutScreen,这是可行的。

情态有什么不同吗?

0 个答案:

没有答案