[英]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.