Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning in Expo Router - Layout children must be of type Screen, all other children are ignored

When I was trying to make folder structure type routes and handling authentication in the main _layout.tsx file and then navigating to different folder route on the basis if the user is authenticated or not. code...

I am using clerk provider

The warning - Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom . Update Layout Route at: "app/_layout"

Is there any way to solve this warning?

      <Stack>
        <SignedIn>
          <Stack.Screen
            name="(signin)"
            options={{
              headerShadowVisible: false,
              headerTitle: "",
              header: () => <View style={{ height: 50 }}></View>,
            }}
          />
        </SignedIn>
        <SignedOut>
          <Stack.Screen
            name="(signout)"
            options={{
              headerShadowVisible: false,
              headerTitle: "",
              header: () => <View style={{ height: 50 }}></View>,
            }}
          />
        </SignedOut>
      </Stack>

This is the code that I used

like image 884
Akshmit Saxena Avatar asked Nov 15 '25 22:11

Akshmit Saxena


1 Answers

The Stack component expects Screen children components only, e.g. Stack.Screen.

Move your providers outside of the Stack component:

      <SignedIn>
        <SignedOut>
          <Stack>
            <Stack.Screen
                name="(signin)"
                options={{
                  headerShadowVisible: false,
                  headerTitle: "",
                  header: () => <View style={{height: 50}}></View>,
                }}
            />
            <Stack.Screen
                name="(signout)"
                options={{
                  headerShadowVisible: false,
                  headerTitle: "",
                  header: () => <View style={{height: 50}}></View>,
                }}
            />
          </Stack>
        </SignedOut>
      </SignedIn>

like image 143
Leroy Dunn Avatar answered Nov 17 '25 22:11

Leroy Dunn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!