I am working on an Ionic react application (v5.0.7).
I have all my paths inside <IonRouterOutlet>.
For the navigation stack management, setting root I am using history.replace() method, but it is not navigating to that screen.
I have a scenario like. From the login screen after the correct login, I want to set root as a Home screen. So I am using history.replace() to navigate to the Home screen, but the home page is not shown (willEnter,DidEnter none of the methods are called).
In Route element, if I console in the render method of home it prints the log, and in Ionic serve the URL is also changed on the top but the page is not changed (no error in console for this)
Now with the same code if I just change history.replace() to history.push(). it starts working and navigate to the home page, but it will allow logged in user to go back to the login screen without login
What can be an issue in this as it is not displaying the home screen
I never use the history prop and haven’t had any problems which is why I asked, also if there is a issue with useHistory() then I believe an issue should be logged so that other people dont get confused and start to hack solutions unnecessarily
I was experiencing a similar issue where signing in worked the first time but on the second sign in the signin page was still displayed. Both pages could still be seen in the debug elements screen but “ion-page-hidden” class was attached to the wrong page.
In my case the error was on the signOut route I had specified routerDirection=“none” for some reason. When I changed “none” to “root” expected behaviour returned.