Hi everyone,
I have built my route stack as the Authentification React Navigation advise : https://reactnavigation.org/docs/en/auth-flow.html
My problem is : when I call a deeplink, the screen is open before I load my config. In my case, I load the user, but also get a new token etc… So for example I call the deeplink to open the screen “me”, it open the screen before I load the user, the token etc…
How can I catch my deeplink, load my config and the navigate to the asked screen ?
Here is my routes.tsx :
const MainNavigation = createSwitchNavigator(
{
App: { screen: AppStack, path: '' },
Auth: { screen: AuthStack, path: '' },
AuthLoading: { screen: AuthLoading, path: '' }
},
{
initialRouteName: 'AuthLoading'
}
);
export default createAppContainer(MainNavigation);
And here is my AuthLoading component :
class AuthLoading extends React.Component<Props> {
constructor(props: Readonly<Props>) {
super(props);
this._bootstrapAsync();
}
_bootstrapAsync = async () => {
const {
getUser,
getNewToken
} = this.props.user;
try {
const user: UserType = await getUser();
if (user) {
await getNewToken();
const { loadEnvironment } = this.props.config;
await loadEnvironment(getToken());
this.props.navigation.navigate('App');
} else {
this.props.navigation.navigate('Auth');
}
} catch (e) {
logout();
}
};
public render() {
return (
<ImageBackground
style={{ flex: 1 }}
source={require('../../assets/splash_screen.png')}></ImageBackground>
);
}
}