WARN Found screens with the same name nested inside one another. Check:
DrawerNavigator > MainTabNavigator > ServiceScreen, DrawerNavigator > MainTabNavigator > ServiceScreen > ServiceScreen
This can cause confusing behavior during navigation. Consider using unique names for each screen instead. BaseNavigationContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.ywh:147787:28 ThemeProvider@http://localhost:8081/index.bundle?platform=ios&dev=true
通过这个层级关系可以看出,写代码的过程中出现名称相同的Screen组件。
- DrawerNavigator > MainTabNavigator > ServiceScreen,
- DrawerNavigator > MainTabNavigator > ServiceScreen > ServiceScreen
虽然是一个警告,但是看着还是很难受的。
解决办法因为我用Stack把ServiceScreen又嵌套了一层,让它能有header。但是写的时候忘记修改名称了。
const ServiceStackScreen = ({navigation}: any) => {
return (
);
};
screenName={‘ServiceScreen’}修改成screenName={‘ServiceStackScreen’} 问题解决。
总结粗心导致的问题。