In case you have such an issue, and verify that you don’t call history.push()
2 times, check your content for an iframe
.
TL; DR: React tries to minimize re-rendering and will reuse the iframe element by just changing its src
. This will update the history object, which is apparently shared with the main page (and would need to press the back button multiple times).
The solution is to add a unique key to the iframe
(I used the src
URL itself)
Here is a blog post that explains the issue in-depth:
https://www.aleksandrhovhannisyan.com/blog/react-iframes-back-navigation-bug/