(preact-iso): Router: Fix change location after useLocation().route()#424
Merged
developit merged 2 commits intopreactjs:mainfrom Mar 14, 2021
Merged
Conversation
🦋 Changeset detectedLatest commit: 0bbb8cc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
||
| const UPDATE = (state, url, push) => { | ||
| const UPDATE = (state, url) => { | ||
| let push = true; |
Member
There was a problem hiding this comment.
How can we get to the else if (push === false) history.replaceState(null, '', url); now?
Contributor
Author
There was a problem hiding this comment.
We cannot. however we never could (the UPDATE method is not exported, just the route(url) is). Now it's just obvious to notice.
Please read this PR description for explanation and try to get to evaluate history.replaceState on master branch if you can.
developit
approved these changes
Mar 14, 2021
developit
approved these changes
Mar 14, 2021
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At this moment routers' reducer dispatcher behaves as follows:
User action (MouseEvent):
window location is updated via
history.pushStateUser navigation via back/ forward (PopStateEvent):
window location is left intact, as it's change is handled by browser
Manual route change via
useLocation().route(path)window location is left intact
This PR
history.pushStateis used to add new entry to browsers history and in effect location changes.pushfrom dispatcher argument to function code block, As reducer dispatchers consume only two arguments. it gave false indication that the argument may be chosen somehow.pushto false and in effect usehistory.replaceState