I am using @react-navigation/native upgraded current version but i am trying to reset the index 0 using the CommonAction.reset() not working
scenerio: I am in the login page once i loggined the splash screen in my root stack initially showing 3 seconds delay then navigate tot eh dashboard my question is why the splash screen is showing initially i already tried lot of things to reset the initialScreen while login or logout not working
type SplashScreenProp = NativeStackNavigationProp<RootStackParamList, 'Splash'>;
const Splash = () => {
const navigation = useNavigation<SplashScreenProp>();
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [{ name: 'TabRoot' }],
})
);
const RootNavigator = () => {
return (
<HeaderButtonsProvider stackType="native">
<RootStack.Navigator
screenOptions={{
headerBackTitleVisible: false,
headerTitleStyle: screenOptions,
headerTitleAlign: 'center',
}}>
<RootStack.Screen name="Splash" component={Splash} options={{ title: '', headerShown: false }} />
<RootStack.Screen name="Login" component={Login} options={{ title: '', headerShown: false, animation: 'fade' }} />
<RootStack.Screen name="TabRoot" component={TabNavis} options={{ title: '', headerShown: false }} />
<RootStack.Screen
name="Settings"
component={Settings}
options={{
title: 'Settings',
headerTitleStyle: screenOptions,
}}
/>
Aravinthan R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.