小编H. *_*bar的帖子

使用navigationOptions在React Navigation中根据状态更改Bottom选项卡栏

我想根据启用的功能更改屏幕上的底部选项卡.此功能列表通过登录API调用填充.

目前我有以下内容:

const TabRouteConfig = {
  Home: DashboardScreen,
  FeatureA: FeatureA,
  FeatureZ: FeatureZ,
};

const TabNavigatorConfig = {
  initialRouteName: 'Home',
  order: [
    'Home',
    'Feature A',
  ],
  tabBarPosition: 'bottom',
  lazy: true,
};

const TabNavigator1 = createBottomTabNavigator(
  TabRouteConfig,
  TabNavigatorConfig,
);

// Set the tab header title from selected route
// https://reactnavigation.org/docs/en/navigation-options-resolution.html#a-stack-contains-a-tab-navigator-and-you-want-to-set-the-title-on-the-stack-header
TabNavigator1.navigationOptions = ({ navigation }) => {
  const { index, routes } = navigation.state;
  const { routeName } = routes[index];

  return {
    headerTitle: routeName,
  };
};

const TabNavigator2 = createBottomTabNavigator(
  TabRouteConfig,
  { …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

7
推荐指数
1
解决办法
2145
查看次数

标签 统计

react-native ×1

react-navigation ×1