在多个StackNavigator React Navigation之间传递数据

时间:2018-11-07 11:18:10

标签: react-native react-navigation

const CategoriesStack = StackNavigator({
  Category: {
    screen: CategoryScreen,
    navigationOptions: () => ({
      tabBarVisible: true,
      header: null
    }),
  },
  Product: {
    screen: ProductScreen,
    navigationOptions: () => ({
      tabBarVisible: false
    }),
  }
},
{
  initialRouteName: 'Category',
  navigationOptions: {
    headerTitleStyle: {
      fontWeight: 'normal',
    }
  }
});

...

const HomeStack = StackNavigator({
  Home: {
    screen: HomeScreen,
    navigationOptions: () => ({
      tabBarVisible: true,
      header: null
    }),
  },
  Search: {
    screen: SearchScreen,
    navigationOptions: () => ({
      tabBarVisible: false,
      header : null
    }),
  }
}, 
{
  initialRouteName: 'Home',
  navigationOptions: {
    headerTitleStyle: {
      fontWeight: 'normal',
    }
  }
});

因此,我在Tab导航器中绑定了两个Stack导航器。从HomeStack-> HomeScreen,我需要将数据传递到CategoriesStack->初始路由名称。我找不到办法。

我不知道该怎么做。

Please refer

0 个答案:

没有答案