New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log In Screen #14
Comments
Try to render conditional routes in the "genRootNavigator" function. |
Hey, it's not recommended to add any logic inside Better way would be to describe // src/screens/index.ts
export const AuthNavigator = (): JSX.Element =>
genStackNavigator([screens.Login, screens.Registration, screens.ForgotPassword]); // src/app.tsx
export const AppNavigator = observer(() => {
useColorScheme();
const {nav} = useServices();
const {auth} = useStores();
return (
<>
<StatusBar barStyle={getThemeStatusBarStyle()} backgroundColor={getThemeStatusBarBGColor()} />
<NavigationContainer
ref={nav.n}
onReady={nav.onReady}
onStateChange={nav.onStateChange}
theme={getNavigationTheme()}
>
{!!auth.currentUser ? <RootNavigator /> : <AuthNavigator />}
</NavigationContainer>
</>
);
}); Or there is also the other way - you can describe Whatever works better for you. |
@kanzitelli after the successful login, how can I redirect to a screen in the RootNavigator? |
hey @nykolaslima! Could you elaborate more on your use case? I have a possible solution in mind but maybe yours is something different. |
Thanks for the fast response @kanzitelli ! I'm pretty new to react/react native, so maybe it's quite simple to solve. I've implemented your suggested solution and after the successful login I'm trying to redirect to the
And I get the following error:
The navigators were configured this way:
What am I missing here? |
@nykolaslima no problem! I just like checking GitHub on Sunday night 😁 So from what I can see, you don't need to do Make sure that you set Let me know how it goes! |
I tried this and if the app is reloaded (closing it and opening again) then the RootNavigator is shown with the expected tabs. But after clicking into the login button and setting the |
@nykolaslima is your AppNavigator wrapped with mobx’s observer(…) function? |
It worked with the observer in the AppNavigator:
Thank you very much @kanzitelli :) |
@nykolaslima awesome, glad it helped! :) |
What is the correct way of implementing a login screen in this template?
I have tried storing the logged in user in a store, and using a conditional render in the RootNavigator but I am having errors.
The text was updated successfully, but these errors were encountered: