Skip to content
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

allow histories to cancel location updates #103

Closed
wants to merge 1 commit into from

Conversation

jlongster
Copy link
Contributor

This is spawned from #100. Right now if a browser doesn't support pushState (or the user is forcing full refreshes), the router still immediately calls listeners, meaning react-router still tries to immediately render the new location within the same page, even though a full reload has been triggered. This causes glitches when navigating: the page changes (most likely to an invalid state) and then a second later the whole thing reloads.

This allows finishTransition in createBrowserHistory to return false when reloading the whole page to cancel location updates, so nothing happens.

@taion
Copy link
Contributor

taion commented Oct 14, 2015

Could you include the update to createBrowserHistory that makes it use this behavior as well, when HTML5 history isn't supported?

@jlongster
Copy link
Contributor Author

Done!

@taion
Copy link
Contributor

taion commented Oct 14, 2015

LGTM. The only potential concern I have is using false as the sentinel, but I can't think of anything better.

I'll let someone else merge this as well :D

@@ -114,8 +114,9 @@ function createHistory(options={}) {
return // Transition was interrupted.

if (ok) {
finishTransition(nextLocation)
updateLocation(nextLocation)
if(finishTransition(nextLocation) !== false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing space after if

@mjackson
Copy link
Member

Thanks, @jlongster! Great call.

And thanks for the review, @taion and @gaearon. I'll manually rebase and merge.

@mjackson
Copy link
Member

Merged in 0148f1f

@mjackson mjackson closed this Oct 15, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants