'initial Route name not working in React native expo project
I am making an instagram clone. i have made it upto navigation. but in my expo app the screen which is added 1st after Stack.Navigator (in below case it is homescreen) shows up on th app, but if i change the initial route name to the second screen it has no effect and still the homescreen shows up. However if i add the 2nd screen before the 1st screen in the code below the 2nd screen shows up.
initial route name seems to have no effect.
import Homescreen from './screens/Homescreen';
import NewPostScreen from './screens/NewPostScreen';
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';
const Stack = createStackNavigator();
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator initialRoutName="1" screenOptions={{ headerShown: false }}>
<Stack.Screen name="1" component={Homescreen} options={{ title: 'Home' }} />
<Stack.Screen name="2" component={NewPostScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
Solution 1:[1]
The prop name is wrong. The right name is initialRouteName. Please, rename it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | marcelofreires |
