Hello all,
I’ve hit a wall with f7 router (5.3.2) and react.
I’ve created a view this way:
<App params={f7Params}>
<View url="/login" main>
</View>
</App>
and in componentDidUpdate there’s a check that says, if the login was successful, navigate to the main page, something like this:
if (RaApiAuth.isAuthenticated() && this.$f7router.currentRoute.url !== "/main/") {
this.$f7router.navigate('/main/');
return;
}
After this the view component, as observed with the react developer tools on chrome, contains both the login and the main component, as it should be.
Whenever the user clicks on the logout button, user login info are deleted for the current session and then the following code gets processed:
componentDidUpdate(prevProps, prevState, snapshot) {
if (!RaApiAuth.isAuthenticated() && this.$f7router.currentRoute.url !== “/login/”) {
this.$f7router.navigate(’/login/’);
}
};
This is similar to the previous snippet, it is simply a matter of navigating back to the login page.
Problem is, now the view has two instances of /login/, and they both receive / fire events, creating unpredictable behaviour.
This is what I am talking about:
Any ideas?
Thanks for your time