Use customHistory url instead of internal url in render if available#140
Open
hesselbom wants to merge 1 commit intopreactjs:mainfrom
Open
Use customHistory url instead of internal url in render if available#140hesselbom wants to merge 1 commit intopreactjs:mainfrom
hesselbom wants to merge 1 commit intopreactjs:mainfrom
Conversation
Member
|
@hesselbom how are you blocking the history change? Just trying to set up a demo. |
Author
/** @jsx h */
import { h, render } from 'preact'
import { Router, Link } from 'preact-router'
import createHistory from 'history/createBrowserHistory'
let history = createHistory()
history.block('Are you sure you want to leave this page?')
let ViewOne = () => <Link href='/two'>Go to view two</Link>
let ViewTwo = () => <Link href='/'>Go to view one</Link>
render((
<Router history={history}>
<ViewTwo path='/two' />
<ViewOne default />
</Router>
), document.body)When trying to switch view but canceling in the prompt the view will update but the url won't. |
Member
|
oh wow, I didn't know |
Author
|
Neither did I until I conveniently found it when needed for a very specific use case! ;) |
Member
|
Just circling back to this - shouldn't this handler be getting fired to take block() into account? |
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.
Currently, when using 'history' module as customHistory, and blocking the history change, the internal state url in Router is still updated, even if window location isn't. This pull request aims to fix this.