Prompt not working as intended for history.push and browser back button
See original GitHub issueVersion
5.2.0
Steps to reproduce
We are using Prompt
for history.push
and browser back button
. When we are clicking on either of them, and then click on Cancel
, the url first changes to new url. Then it gets back to previous url, but the state
is reset
. Due to this, we are losing the progres.
Expected Behavior
By clicking on cancel
, the state should not get reset, it should maintain itself. While only when we click on OK
, state should reset and view should be forwarded to new view (according to url).
Actual Behavior
State is getting reset, with url being changed even though we are clicking on cancel
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:5
Top Results From Across the Web
React-router v4 this.props.history.push(...) not working
So I came to this question hoping for an answer but to no avail. I have used const { history } = this.props;...
Read more >5.4 Session history and navigation — HTML5 - W3C
When the user navigates through a browsing context, e.g. using a browser's back and forward buttons, the user agent must traverse the history...
Read more >Designing A Better Back Button UX - Smashing Magazine
We've all been in a situation when a browser's “Back” button just didn't work as expected, driving us away from the goal, ...
Read more >Handling common JavaScript problems - MDN Web Docs
As we said in the previous article on HTML/CSS, you should make sure your code is working generally, before going on to concentrate...
Read more >Disabling back button in React with react-router v5 - Ye Joo Park
Create a top-level <Route> in <BrowserRouter> that matches all URLs ( / ) and render App component. · Get history object by wrapping...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you use window.history.go, you will have the problem of switching between old and new URLs. The browser will display the new URL, but inside the React -Router, it is still the old URL, so its state is old
I think you can this: