Closed sofilay closed 1 year ago
same here
Yeah I had the same issue. It seems to work if you add a _layout.tsx
in each tab's subfolder like:
// app/(tabs)/home/_layout.tsx
import {Stack} from "expo-router/stack";
export default function HomeLayout() {
return (
<Stack>
<Stack.Screen name="index" />
</Stack>
)
}
In app/_layout.tsx
add (tab) to stack screen to register it
// app/_layout.tsx
...
return (
<QueryClientProvider client={queryClient}>
<View style={{ flex: 1 }} onLayout={onLayoutRootView}>
<Stack
initialRouteName="index"
screenOptions={{headerShown: false}}
>
<Stack.Screen name="index" />
<Stack.Screen name="register" />
<Stack.Screen name="(tabs)" /> // <---
</Stack>
</View>
</QueryClientProvider>
);
In
app/_layout.tsx
add (tab) to stack screen to register it// app/_layout.tsx ... return ( <QueryClientProvider client={queryClient}> <View style={{ flex: 1 }} onLayout={onLayoutRootView}> <Stack initialRouteName="index" screenOptions={{headerShown: false}} > <Stack.Screen name="index" /> <Stack.Screen name="register" /> <Stack.Screen name="(tabs)" /> // <--- </Stack> </View> </QueryClientProvider> );
I did it! but doesn't work for me :(
I solved it commenting this lines in the app/index:
export const unstable_settings = {
initialRouteName: 'index',
};
And I added a _layout.tsx inside the app/(tabs)/home components with this code:
import React from 'react'
import { Stack } from 'expo-router'
const StackLayout = () => {
return (
<Stack>
<Stack.Screen name='index' options={{
headerTitle: 'Home Screen'
}}/>
</Stack>
)
}
export default StackLayout
Thank you for the help!
Which package manager are you using? (Yarn is recommended)
yarn
Summary
Hello!
I'm ussing: "expo-router": "2.0.0" "expo": "~49.0.5" "react-native": "0.72.3"
I have a strange behavior in routing. I want to create a bottom bar navigation. Inside my app folder is structured as follows:
Any time I want to create a _layout so I create the tabs inside (tabs) throws me this error:
and then the screen goes blank. I do have an index inside the home folder and if I delete that _layout.tsx the redirection works. Anyone with the same problem?
Minimal reproducible example
// app/index.tsx
// app/_layout.tsx
// app/(tabs)/_layout.tsx
// app/(tabs)/home/index.tsx