[SOLVED] How to solve View Init being called repeatedly

Problems: View Init is called repeatedly every time the back button is pressed.

I have three different pages which are:

  1. Home
  2. Information → Account

When I go to the “Account” page and press the back button, it should lead to the “Information” page. However, when I press it, it leads to the “Home” page instead.

After I looked for the cause it was sourced in app.f7.html in the following code:

<div class="view view-init view-main ios-edges" data-url="/"></div>

Then for the code in account.f7.html is as follows:

<a href="#" class="link back"><i class="icon f7-icons arrow-back">arrow_left</i></a>

Can someone help me solve this problem? I’ve been struggling for several hours but it hasn’t been resolved at all. All I want is for the back button to not call View Init again when pressed.

The technology I use:

  1. Framework7 version 7.0.5
  2. Node version 16.0.2

I have successfully solved the problem. I don’t know if this is true or not but when I tried it, it worked.

In app.f7.html I changed the data-url to the following:

<div class="view view-init view-main ios-edges" data-url="/base/"></div>

And in route.js I added a new route, namely:

{
	path: '/base/',
	component: isUserLoggedIn() ? GHomePage : GSignInPage
}

Then the function I use to check users is as follows:

function isUserLoggedIn() {
	if(typeof localStorage !== "undefined") {
		const isLogged = localStorage.getItem('is_logged');
		return isLogged === 'true';
	}else {
		return false;
	}
}

I like your use of conditional component.