ScreenParams使用带有tabnavigator的stacknavigator返回未定义

时间:2018-09-12 01:35:25

标签: react-native react-navigation

我在TabNavigator中有堆栈导航器,我正在尝试使用screenProps将对象传递到所有屏幕。当我将screenProps分配给一个对象并在其中一个屏幕中控制台this.props时,我得到“ screenProps”:未定义

 const home = createStackNavigator(
 {
    Home: {
        screen: Home //React component imported from another file
    }, 
 },
 {
    mode: 'modal',   
 }
);

const account = createStackNavigator(
 {
    Account: {
        screen: Account //React component imported from another file
    },
 },
 {
    mode: 'modal',   
 }
);

export default TabNavigator({
  Home: { screen: home }, 
  Account: { screen: account },
 },
  {
  navigationOptions: ({ navigation, screenProps }) => ({}),
 }
);

//Using TabNavigator
<TabNavigator onNavigationStateChange={null} screenProps={{'test': 'value'}}/>

0 个答案:

没有答案