从子导航器设置导航器参数?

时间:2019-02-03 04:40:50

标签: react-native react-navigation

我有一个嵌套在标签导航器(RecipesTab中的堆栈导航器(NavBar),并且我试图隐藏RecipeSite上的标签栏。我当前的解决方案是将showTabBar传递到树上,但是我无法设置NavBarRecipesTab的导航参数。想知道是否可能以某种方式从this.props.navigation.setParams({...})导航器调用RecipesTab或以另一种方式将参数从NavBar传递到RecipesTab

//class RecipeList...
//class IngredientsTab...

class RecipeSite extends Component {
    render() {
        this.props.navigation.setParams({showTabBar: false});
        return;
    }
}

const RecipesTab = createStackNavigator(
    {
        Main: {
            screen: RecipeList,
        },
        Site: {
            screen: RecipeSite,
        }
    },
    {
        initialRouteName: 'Main',
    }
);

export default NavBar = createBottomTabNavigator(
    {
      Recipe: {
        screen: RecipesTab,
        navigationOptions: ({ navigation }) => ({
          tabBarVisible: navigation.getParam('showTabBar', true)
        }),
      },
      Ingredient: {
        screen: IngredientsTab,
      }
    },
  );`

基本上,我只是想将数据从RecipesTab发送到NavBar

0 个答案:

没有答案