[SOLVED] Page component gets rendered without calling his route

Any idea what can be wrong with my route?
Whe i navigate from HomePage to FirmaPage and then i press Back
then the app work correctly returning to the HomePage but in the console.log
i see that CercaPage gets called (render + mount).
What i did wrongly?

import {checkAuth, checkFirmaAuth} from '../laco/auth';
import {HomePage} from '../pages/HomePage';
import {NotFoundPage} from '../pages/NotFoundPage';
import {LoginPage} from '../pages/LoginPage';
import {QrCodePage} from '../pages/QrCodePage';
import {FirmaPage} from '../pages/FirmaPage';
import {CercaPage} from '../pages/CercaPage';
import {Router} from "framework7/modules/router/router";


export const routes: Array<Router.RouteParameters> = [
	{
		path: '/',
		component: HomePage as Router.Component,
		beforeEnter: checkAuth,
	},
	{
		path: '/login/',
		component: LoginPage as Router.Component,
	},
	{
		path: '/email/',
		component: CercaPage as Router.Component,
		beforeEnter: checkFirmaAuth,
	},
	{
		path: '/qrcode/',
		component: QrCodePage as Router.Component,
		beforeEnter: checkFirmaAuth,
	},
	{
		path: '/firma/',
		component: FirmaPage as Router.Component,
		beforeEnter: checkFirmaAuth,
	},
	{
		path: '(.*)',
		component: NotFoundPage as Router.Component,
	},
];

Ideally this can’t happen. But i would suggest that if you use pushState then that page could be in history so it preloads it

Uhm… i navigate only using the Link component with the Href attribute
or by using getInstance().views.main.router.navigate(url).
I will try to see if the problem is, when developing, it livereloads, and maybe the “homepage” is not “/” but another page… so i’ve to clear the history when navigating home when beforeEnter fails?

Antonio, I have found that when pushState is enabled framework7 stores the page urls in the browser localStorage. And the pages get pre-loaded even if you clear cache, etc. Took me a while to figure it out. Good luck!

1 Like

Uhm… definitively something i dislike for my kind of application. Thanks for the advice :slight_smile: !!!

The solution is to set preloadPreviousPage=false on the View.

Another solution is to make sure to use {reloadAll:true} when navigating, expecially in beforeEnter router’s guards.