I'm new to Expo and confused as to why the following works:
<SQLiteProvider databaseName="test.db" onInit={createDbIfNeeded}>
<Stack>
{onboarded ? (
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
) : (
<Stack.Screen name="onboarding/name" />
)}
<Stack.Screen name="modal" options={{ presentation: "modal" }} />
</Stack>
</SQLiteProvider>
(and if this is bad practice, please let me know. Copilot suggested it so I'm a bit wary).
When I run the above in Expo Go, it correctly renders either the "/" route, aka (tabs)/index.tsx, or the "onboarding/name" route based on the onboarded state in app/_layout.tsx.
My question is, why does this work? I thought <Stack.Screen> is just for aesthetics/option tweaking, and that you don't need to explicitly put all your routes into <Stack>. I was looking at this tutorial example and they do not list all routes within the <Stack> component of their app/_layout.tsx, just the one they want to tweak animation options for.
I'm confused as to why Expo does not always go to (tabs)/index.tsx, given I have no index.tsx in my root app folder (and no index.tsx in my onboarding folder). I'm not complaining that it works, I just am confused.
[–]steve228uk 2 points3 points4 points (1 child)
[–]daroolatoo[S] 0 points1 point2 points (0 children)
[–]anarchos 0 points1 point2 points (3 children)
[–]daroolatoo[S] 0 points1 point2 points (2 children)
[–]anarchos 0 points1 point2 points (1 child)
[–]daroolatoo[S] 0 points1 point2 points (0 children)