-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Directly called window.history.pushState
is ignored by RR 3.2.1
#6304
Comments
history.pushState
is ignored by RR 3.2.1window.history.pushState
is ignored by RR 3.2.1
You will need to navigate using your application's
This only works for navigation performed by the const history = createBrowserHistory();
history.listen(() => {
console.log("ooh, a navigation!");
});
history.push("/abou");
// console
> ooh, a navigation! Navigation outside of a |
Thanks for the quick answer! But that's completely not what I was looking for. Unfortunately, I cannot use RR's Any other suggestions? Please reopen... |
Your app's As for possible solutions, you can create a history module that is importable throughout your application so that you can navigate from outside of React. // history.js
import { createBrowserHistory } from "history";
// actual implementation might be slightly more involved
// see: https://github.com/ReactTraining/react-router/blob/v3/modules/browserHistory.js
export default createBrowserHistory(); // react-app.js
import history from "./history";
ReactDOM.render(
<Router history={history} />,
root
); // main-app.js
import history from "./history";
history.push({ pathname: "/about" }); |
Yep, looks like sharing the history object is the only possible solution... |
I am using quite an outdated version of RR and I am facing an issue when directly called
windown.history.pushState
is ignored by RR 3.2.1.Version
"react-router": "3.2.1"
Test Case
https://codesandbox.io/s/84w232m6r9
Steps to reproduce
Simply click "Go to About" which will call
window.history.pushState(null, null, '/about')
.Expected Behavior
Router transitions to appropriate page.
Actual Behavior
Nothings happens.
The text was updated successfully, but these errors were encountered: