Hello!
I am still trying to do user authentication. My router returns different routes depending on isAuthenticated.
But the problem is that Framework7 is already ready when useAuth() returns a token and isAuthenticated is set to false, not waiting for a token. Is it possible to somehow change the routes of the application when the data finally comes up? Do not add, but completely replace. And pass user data to the application.
const MyApp = () => {
let {token, login, logout, userId, ready} = useAuth()
let isAuthenticated = !!token
let routes = useRoutes(isAuthenticated)
// Framework7 Parameters
let f7params = {
token: token,
name: 'VOL Messenger',
....
};
if (!ready) {
return (
<App { ...f7params }>
<Loader />
</App>
)
}
f7params.name = "dddd"
f7params.ready = ready
f7params.routes = routes
console.log(f7)
return (
<App { ...f7params }>
{/* Your main view, should have "view-main" class */}
<View main className="safe-areas" url="/" />
</App>
);
}
export default MyApp;