I have two stack navigators for my app. Only one should show up, based of the isLoggedIn condition. However, both show when isLoggedIn = true . But when I set the condition to false , it only shows app. I simply dont get it.
export default function App() {
const isLoggedIn = true;
return (
<NavigationContainer>
<Stack.Navigator>
{isLoggedIn === true ? (
<Stack.Screen name="Auth" component={AuthStackNavigator} />
) : (
<Stack.Screen name="App" component={AppBottomTabNavigator} />
)}
</Stack.Navigator>
</NavigationContainer>
);
}
Could you try this.
export default function App() {
const isLoggedIn = true;
return (
<NavigationContainer>
<Stack.Navigator>
{isLoggedIn === true && <Stack.Screen name="Auth" component={AuthStackNavigator} />}
{isLoggedIn === false && <Stack.Screen name="App" component={AppBottomTabNavigator} />}
</Stack.Navigator>
</NavigationContainer>
);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.