-
Notifications
You must be signed in to change notification settings - Fork 961
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
revertPop not work correctly #563
Comments
Moreover, it breaks logic of successive transitions. I can't reproduce it sandbox, but in normal browser it's reproducible stably. Let's take the basic example https://reacttraining.com/react-router/web/example/basic and slightly modify it: import React from 'react'
import {
Router,
Route, Switch,
Link,
Prompt,
} from 'react-router-dom'
// ---
import { createHashHistory } from "history"
const history = createHashHistory()
const blocker = (location, action) => {
if (location.pathname.indexOf("about") !== -1) {
console.log("blocked")
return false
}
}
// ---
const Home = () => (
<div>
<h2>Home</h2>
</div>
)
const About = () => (
<div>
<h2>About</h2>
</div>
)
const Topics = () => (
<div>
<h3>Topics</h3>
</div>
)
const BasicExample = () => (
<Router history={history}>
<div>
<Prompt when={true} message={blocker} />
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
<li><Link to="/topics">Topics</Link></li>
</ul>
<hr/>
<Route exact path="/" component={Home}/>
<Switch>
<Route path="/about" component={About}/>
<Route path="/topics" component={Topics}/>
</Switch>
</div>
</Router>
)
export default BasicExample Now, try following scenario:
Expected behavior:
Actual behavior: Why |
Thank you @minzojian for putting together a great test case. Just spent the last hour debugging through react-router-navigation-prompt to come to the same discovery. When I use try to stop a goBack() call - it works Anyone find a workaround? |
This is a known issue that we cannot fix. Blocking will be removed in the next major version (see #690 for rationale). |
please check the sandbox demo
suppose i jump from / to /pageA via click the link
i use a promt and force stop this navigation
render stoped(still render index page), however,the address has changed into /pageA
it suppose to back to /
check the source code debug snapshot
it looks allPaths only add new record when did history push action, why hash change not modify all paths?
The text was updated successfully, but these errors were encountered: