props.history.goBack() not working in iOS WeChat browser after first history.push('xxx')

Viewed 607

I have tested many times for this behavior and found the bug only in iOS WeChat after first history.push()

For example: in the Main page i click a link (using history.push) and jump into page A, but the back button (using props.history.goBack()) does not work. When I click a link (using history.push) in page A, I jump into B page, the back button in page B can go back to page A and now the back button in page A is working fine (meaning that I can go back to the Main page).

No such strange behavior in Android WeChat.

In iOS WeChat, you must jump 2 times to have normal behaviour. Without the second jump operation you cannot go back through the first jump.

Both HashBrowser and BrowserRouter have this bug/error behaviour.

below is my relation package

"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-router-dom": "^5.2.0",
1 Answers

Replacing history.goBack() with history.go(-1) should provide you with the same functionality and work in both Android and Safari.

Related