【问题标题】:React native createBottomTabNavigator反应原生 createBottomTabNavigator
【发布时间】:2021-08-03 16:53:35
【问题描述】:

我正在尝试创建BottomTabNavigator,但出现以下错误

警告:React.createElement:类型无效 - 应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。您可能忘记从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。 检查BottomTabNavigator的渲染方法。 在 BottomTabNavigator 中(在 AppRoot.js:76)

这是我的代码

const Stack = createStackNavigator();
const Drawer = createDrawerNavigator();
const Tab = createBottomTabNavigator();
// stacks
const StackApp = () => {
  return (
    <Stack.Navigator initialRouteName="SplashScreen">
      <Stack.Screen
        name="Log_In"
        component={Log_In}
        options={{ headerShown: false }}
      />
      <Stack.Screen
        name="Sign_Up"
        component={Sign_Up}
        options={{
          title: "Create Account",
          headerStyle: { backgroundColor: "#fcf5f3" },
          headerTitleStyle: {
            fontWeight: "bold",
          },
        }}
      />
      <Stack.Screen
        name="HomeScreen"
        component={HomeScreen}
        options={{ headerShown: false }}
      />
      <Stack.Screen
        name="SplashScreen"
        component={SplashScreen}
        options={{ headerShown: false }}
      />
      <Stack.Screen name="UserResetPassword" component={UserResetPassword} />
      <Stack.Screen name="UserProfileScreen" component={UserProfileScreen} />
      <Stack.Screen name="EditeProfileScreen" component={EditeProfileScreen} />
    </Stack.Navigator>
  );
};


export default function AppTabs() {
  return (
    <NavigationContainer>
      <Tab.Navigator>
        <Tab.Screen name="Home" component={StackApp} />
      </Tab.Navigator>
    </NavigationContainer>
  );
}

【问题讨论】:

  • 这是完整的代码吗,在寻求帮助之前,您应该先尝试使用错误消息解决您的问题。
  • 我试了很多次。但我什么也没做

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


【解决方案1】:

react-navigation/bottom-tabs 版本6.0.2 中存在关于createBottomTabNavigator() 函数的错误。

降级版本5.11.13,它将为您解决问题。我今天遇到了同样的问题,降级效果很好。

【讨论】:

    猜你喜欢
    • 2019-03-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    • 2021-11-07
    • 2021-05-03
    • 2018-03-30
    • 2017-11-09
    • 2018-12-07
    相关资源
    最近更新 更多