Behavior of the Tabnavigator

Asked

Viewed 9 times

0

I created a project in React Native where I return the following Container:

const Tab = createBottomTabNavigator()

authRouter = () => {
    return (
        <Stack.Navigator initialRouteName={Login}>
            <Stack.Screen name="Login" component={Login} options={{ title: "Login" }} />
            <Stack.Screen name="Register" component={Register} options={{ title: "Register" }} />
        </Stack.Navigator>
    )
}

const Navigator = props => {
    return (
        <NavigationContainer>
            <Tab.Navigator
                initialRouteName='Feed'
            >
                <Tab.Screen name="Feed" component={Feed} />
                <Tab.Screen name="AddPhoto" component={AddPhoto} />
                {props.name ? (
                    <Tab.Screen name="Profile" component={Profile} />
                ) : (
                    <Tab.Screen name="Auth" component={authRouter} />
                )}

            </Tab.Navigator>
        </NavigationContainer>
    )
}

As you can see the Navigator returns a Tabnavigator and if props.name is set I add the Profile screen, otherwise I add the authRouter screen.

The problem is that after I login/logout by setting or cleaning the props.name, Tabnavigator displays the Tab.Screen "Feed", not remaining on the Tab.Screen "Profile" or "Auth".

Does anyone know why this behavior???

Thank you for your attention

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.