I am having trouble getting the stack navigator in react native to work. I am just making blank stack navigators to go inside a bottomTabsNavigator. And I get an error referring to using the route.key. Even if I make a simple Stack navigator I still get this error, and can't seem to see any mention of it online anywhere. Any help would be very appreciated :)
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
import Icon from 'react-native-vector-icons/MaterialIcons';
import CartScreen from './screens/CartScreen'
import RecipeScreen from './screens/RecipeScreen'
import ProfileScreen from './screens/ProfileScreen'
const Stack = createStackNavigator();
function Navigator() {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={({ route }) => ({
headerStyle: {
backgroundColor: 'salmon',
},
headerTintColor: 'white',
headerTitleStyle: {
fontWeight: 'bold',
},
})}
tabBarOptions={{
showLabel: false,
activeTintColor: 'white',
inactiveTintColor: 'pink',
style: {backgroundColor: 'salmon', height: 60,}
}}
>
<Stack.Screen name="cart" component={CartScreen} />
<Stack.Screen name="recipe" component={RecipeScreen} />
<Stack.Screen name="profile" component={ProfileScreen} />
</Stack.Navigator>
</NavigationContainer>
)
}
export default Navigator
Solution was to use yarn instead of npm
I had the same problem, and it was the @react-navigation/native and @react-navigation/stack versions installed. Make sure that the 2 libraries have the same version in the package.json file.
Here you have provided the same name in the parent screen and child screens so you are getting this error to have a try with a different name in screen declarations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With