-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initialRouteName has no effect #723
Comments
Only when both |
I am running into this when deep linking from one tab with its own stack to another tab with its own stack. There is no back button for the deep linked page although, |
i know it's not a proper solution. for now am going with this. check out : #428 |
I'm able to use this to impact the router history with groups. My initial problem was I couldn't figure out how to have proper pop/push animations. I always wanted anything in (auth) group to pop and anything in (tabs) to push. Turned out I just had to export this in the root layout: export const unstable_settings = {
initialRouteName: '(auth)',
} |
Well, I'm running into the same issue. After running a few investigations, if you console.log each route component, you see that the components are really mounting, but the redirect is being redirected again to the index of (tabs), for some unknown reason. The render order is "initial route" > "login" > "(tabs)/index". I tested both reloading and from a fresh start. Clearing the cache with -c had no effect. However, if you don't navigate when the app loads, and you do a fast refresh from a change in the code, the route properly initiates in the correct route. However, any attempt to open the app defaults to tabOne in the template. Navigating from the Expo Go app, you go straight to "(tabs)/index". package.json
|
Same issue, I set |
The React Navigation -> Expo Router migration guide seems to imply that the With this in mind I think The docs could probably be a bit clearer that |
I have a case where my new app goes to (auth) >. index.tsx instead of (tabs) > index.tsx. initialRouteName doesnt work |
In that case, specify the initial route like this, |
But I wanted to go to (tabs)/index.tsx. I set the initialRouteName up to "(tabs)". I have up and used redirections |
Very confusing. Not only it doesn't work, but |
I encountered the same issue with 1. Loading Fonts and Authentication State in
|
Same here |
I think all solutions are confused. My solutions: Set the app/_layout.tsx import { useFonts } from "expo-font";
import { Stack } from "expo-router";
import * as SplashScreen from "expo-splash-screen";
import { useEffect } from "react";
import "react-native-reanimated";
SplashScreen.preventAutoHideAsync();
export default function RootLayout() {
const [loaded] = useFonts({
SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"),
});
useEffect(() => {
if (loaded) {
SplashScreen.hideAsync();
}
}, [loaded]);
if (!loaded) {
return null;
}
return (
<Stack >
<Stack.Screen name="index" options={{ headerShown: false }} redirect />
<Stack.Screen name="login" options={{ headerShown: false }} />
<Stack.Screen name="about" options={{ headerShown: false }} />
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="+not-found" />
</Stack>
);
} Index page will redirects to first sibling page |
@osmanemin adding redirect did the trick 🎉🎉 |
I just created an
If |
@andres-dos-santos you are a true hero. It works perfectly. Thank you! |
Which package manager are you using? (Yarn is recommended)
npm
Summary
On a fresh Expo project with tabs and Typescript, the
unstable_settings.initialRouteName
has no effect.I also tested
<Stack initialRouteName=...>
and it also has no effect.Basically, any directory with parenthesis
(something)
alphabetically at the top becomes the default route, unless there is anindex
directory.This doesn't correlate with what's described in the documentation: https://expo.github.io/router/docs/features/routing/#layout-settings
Minimal reproducible example
Steps to reproduce:
Step 1, Environment
Step 2, Testing the effect
Duplicate
(tabs)
directory and rename the duplicate to(a)
Update some text in
(a)/index.ts
Add
<Stack.Screen name="(a)" options={{ headerShown: false }} />
into the<Stack>
Result:
(a)
will be the default route withoutunstable_settings.initialRouteName
is updated. You can set anything tounstable_settings.initialRouteName
, there is no effect.The text was updated successfully, but these errors were encountered: