Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Cannot go back 2 pages using IonReactRouter and useHistory hook #22900

Closed
rluttikhuizen opened this issue Feb 9, 2021 · 2 comments
Closed
Labels

Comments

@rluttikhuizen
Copy link

Bug Report

Ionic version:
[ ] 4.x
[x] 5.x

Current behavior:
In some pages of our Ionic React App we need to go back 2 pages after some action is performed (e.g. button user click). For this we use a go(-2) on the useHistory hook. Current behavior is that the browser address bar shows the correct URL (2 pages back in history), but the page that is shown is the previous page that you would expect from a goBack or go(-1).

Expected behavior:
Expected behavior is that the page that is shown after invoking go(-2) is the page that is 2 pages back in history. Thereby also matching the URL in the browser address bar.

Steps to reproduce:
See https://codesandbox.io/s/ionic-react-usehistory-go-2-zjsh3 for a simple example application. Steps to reproduce in the sandbox:

  1. App opens on Dummy Page 1 (path = /dummy1)
  2. Click on the Dummy Page 2 link
  3. You are forwarded to Dummy Page 2 (path = /dummy2)
  4. Click on the Dummy Page 3 link
  5. You are forwarded to Dummy Page 3 (path = /dummy3)
  6. Click on the button labelled History go(-2)

The URL in the address bar changes into "/dummy1" --> OK
The page that is shown is Dummy Page 2 --> NOK

The sandbox app was created using:

ionic start HistoryDemo blank --type=react

And then just create 3 tsx files each containing a Dummy Page. All Dummy Pages have an IonItem with a routerLink set to the next Dummy Page path. Dummy Page 3 has a IonButton to execute go(-2) using onClick.

Related code:

See https://codesandbox.io/s/ionic-react-usehistory-go-2-zjsh3 for a simple example application.

Other information:

Ionic info:

Ionic:

Ionic CLI : 6.12.4 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 5.5.4

Capacitor:

Capacitor CLI : 2.4.6
@capacitor/core : 2.4.6

Utility:

cordova-res (update available: 0.15.3) : 0.15.1
native-run (update available: 1.3.0) : 1.0.0

System:

NodeJS : v14.15.3 (/usr/local/Cellar/node@14/14.15.3/bin/node)
npm : 6.14.9
OS : macOS Big Sur

@ionitron-bot ionitron-bot bot added the triage label Feb 9, 2021
@liamdebeasi
Copy link
Contributor

Thanks for the issue. I am going to close this as a duplicate of #22563.

@ionitron-bot
Copy link

ionitron-bot bot commented Mar 11, 2021

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants