使用React Navigation在Stacknavigator中用hoc包装屏幕

时间:2018-12-04 12:43:01

标签: reactjs react-native-android react-navigation

我尝试在响应native中使用Context Api。我想将单个堆栈与全局包装,并将子屏幕与消费者包装在一起。 当我用context.Provider包装整个App(root)容器,并用Context.Consumer包装屏幕时,它工作正常,但单个堆栈出现了问题。

    const HomeStack = createStackNavigator({
    Home: {
    screen:withGlobalContext(HomeScreen),
         // screen: SkillScreen,

    navigationOptions: {
    header: null,
        }},
    Skill: {
         screen: SkillScreen,
         navigationOptions: {
         header: null,
         tabBarVisible: false
         }
     },
    DetailOpp: {
    screen: OppDetailScreen,
    navigationOptions: {
      header: null,
      tabBarVisible: false
     } }
    });

    const AppContainer = createAppContainer(createBottomTabNavigator(
    {
    Home: {
      screen: HomeStack,
      navigationOptions: {
        tabBarIcon: ({ tintColor }) => (
          <Icon name="md-home" size={24} style={{ color: tintColor }} />
        ),
        // tabBarVisible :false
      }
    },

     <GlobalContextProvider>
        <AppContainer />
      </GlobalContextProvider>

像AppContainer一样,它将按预期工作,但我想用提供程序包装单个堆栈

0 个答案:

没有答案