简体   繁体   English

React Navigation bottomTabNavigator“createRouter 不是函数”

[英]React Navigation bottomTabNavigator "createRouter is not a function"

I have created a stackNavigator(for login signup screens) that's working perfectly and then after that I created bottomTabsNavigator but for some reason I am getting this error "Create Router is not a function" check screenshot below:我创建了一个运行良好的 stackNavigator(用于登录注册屏幕),然后我创建了 bottomTabsNavigator 但由于某种原因我收到此错误“创建路由器不是功能”检查下面的屏幕截图:

错误图像

Here is my code:这是我的代码:

 import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; /** Bottom tab navigator */ const Tab = createBottomTabNavigator(); const MyTabs = () => { return ( <Tab.Navigator initialRouteName="Tab1"> <Tab.Screen name="Tab1" component={Tab1} /> <Tab.Screen name="Tab2" component={Tab2} /> </Tab.Navigator> ); }; const App = () => { return ( <Provider store={store}> <NavigationContainer> <MyTabs /> </NavigationContainer> </Provider> ); };

I did exactly what React Navigation 5.x docs recommended but still I faced this issue.我完全按照 React Navigation 5.x 文档的建议做了,但我仍然遇到了这个问题。 Let me know if someone faced something similar.如果有人遇到类似的情况,请告诉我。

Just resolved the issue here.刚刚解决了这里的问题。

I updated to the last version of all libs我更新到所有库的最新版本

"@react-navigation/bottom-tabs": "^5.0.1",
"@react-navigation/core": "^5.1.0",
"@react-navigation/material-top-tabs": "^5.0.1",
"@react-navigation/native": "^5.0.1",
"@react-navigation/stack": "^5.0.1",

and then i deleted my package-lock.json,然后我删除了我的 package-lock.json,

and in your terminal go to android folder and then type ./gradlew clean并在您的终端中转到 android 文件夹,然后键入 ./gradlew clean

after that you should run your npx react-native run-android,之后你应该运行你的 npx react-native run-android,

close your default metro terminal,关闭您的默认地铁站,

and then run npx react-native start --reset-cache,然后运行 ​​npx react-native start --reset-cache,

worked well after doing this这样做后效果很好

Make sure you have installed latest versions of @react-navigation/native and @react-navigation/bottom-tabs :确保您已安装最新版本的@react-navigation/native@react-navigation/bottom-tabs

npm install @react-navigation/native @react-navigation/bottom-tabs

Then clear the cache:然后清除缓存:

npm react-native start --reset-cache

Or if using Expo:或者如果使用世博会:

expo start -c

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 添加自定义按钮以响应导航底部TabNavigator? - Add custom button to react navigation bottomTabNavigator? 在react-navigation中从StackNavigator隐藏BottomTabNavigator的标题 - Hide a header of a BottomTabNavigator from a StackNavigator in react-navigation 在 BottomTabNavigator react-navigation v5 内嵌套 StackNavigator - Nesting StackNavigator inside BottomTabNavigator react-navigation v5 如何在 React Navigation (4.x) 的特定屏幕中隐藏 BottomTabNavigator - How to hide BottomTabNavigator in certain screen in React Navigation (4.x) react-native bottomTabNavigator被Android系统导航栏部分覆盖 - react-native bottomTabNavigator is partially covered by Android system navigation bar 在 React Navigation v3 中单击 React Native 中 bottomTabNavigator 上的选项卡时,如何刷新我的组件? - How do I refresh my component when clicked on tab on bottomTabNavigator in React Native, in React Navigation v3? React Native 嵌套导航以在登录/注册(StackNavigator)后实现带有选项卡(bottomTabNavigator)的登陆屏幕 - React Native nested navigation to achieve a landing screen with tabs (bottomTabNavigator) after Sign-In/Sign-Up(StackNavigator) 反应原生 BottomTabNavigator 奇怪的 Animation - React native BottomTabNavigator Strange Animation React Native BottomTabNavigator 删除空格 - React Native BottomTabNavigator remove white space React Native:以编程方式更改bottomTabNavigator路线 - React Native: Change bottomTabNavigator route programmatically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM