-
Notifications
You must be signed in to change notification settings - Fork 593
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
prevent POP actions to push the url into the history. #76
Conversation
Thanks @lluistfc. Last time I looked into this and found some caveats. Sadly, I forget it now. Let me take a closer look into it again. |
Hello @supasate. Any news on this issue? |
pls check this asap, its a critical issue as the page is rendered twice on browser back action |
Any updates on this? |
Just revisited this issue. I'm not sure that this fix is addressing general cases of clicking back button or only during the time traveling. In the case of clicking the browser back button outside of time traveling, I cannot reproduce this behavior -> "Once in page C we do a browser back, we end on page B -> pop event. but page B gets pushed onto history." From the codebase, page B will be pushed again only if it's in time traveling, i.e. the location in history and the location in redux store are different. By clicking back outside of time traveling, both locations are synced. |
Critical issue. @lluistfc update fixes navigation issues using the browser's back button. |
Here is a (hopefully) a full explanation of what is going on with the code in question: When using the redux dev tools to "time travel" (I.e. replay previous versions of your state) the browser history can become out of sync. The original code was designed to remedy this via the following intended logic:
However, the unintended consequence is the following:
|
@siddhant91 I'm sorry but we depend on @supasate to approve and accept the PR. I've been using the fork I made with my modifications with no issues. I haven't updated it since the modifications I made so it's really outdaded respect this version, give it a try if you want or fork current version and apply that modification. |
any updates on that? |
@@ -35,7 +35,7 @@ const createConnectedRouter = (structure) => { | |||
} = props.history.location | |||
|
|||
// If we do time travelling, the location in store is changed but location in history is not changed | |||
if (pathnameInHistory !== pathnameInStore || searchInHistory !== searchInStore || hashInHistory !== hashInStore) { | |||
if (props.history.action === 'PUSH' && (pathnameInHistory !== pathnameInStore || searchInHistory !== searchInStore || hashInHistory !== hashInStore)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have here some detailed comment to explain why it is important to check the action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we test it to be sure it wont break the next time?
Hi ! Any updates on that ? |
can anyone with permissions fix the .gitignore conflict? |
@jancama2 if I PR this same fix with tests and no |
Is this going to be updated and merged? This fixes #262 |
This also fixes #349. |
Sorry all for keeping this PR for a long time! TBH, I still don't have time to think about it thoroughly, but, it seems to fix many issues listed above. So, I'm merging it first. If anyone finds issues after merging, please let me know! |
Great, thanks ! Do you know when this will be released? |
When using your component with react (v16) + react-router (v4) and react-redux (v5) i've encontered an issue when doing a back from the browser.
If we start on page A and go to page B -> push event.
Once we are on page B we go to page C -> push event.
Once in page C we do a browser back, we end on page B -> pop event. but page B gets pushed onto history.
Back on page B we do a browser back, we end on page C
That behaviour is caused by:
on ConnectedRouter.js#L38
By adding another condition to check if history action is "PUSH" i've managed to avoid this behaviour.