react-router
8.5.1 · 27 Oct 2026MIT80.2M / weekRepositorynpmAtom feed
0.13.6 is the newest release of 0.9.x.
In short
16 changed
Release note
ActiveState mixin isActive
isActive is now an instance method.
// 0.7.x
var SomethingActive = React.createClass({
mixins: [ActiveState],
render: function () {
var isActive = SomethingActive.isActive(...);
}
});
// 0.9.x
var SomethingActive = React.createClass({
mixins: [ActiveState],
render: function () {
var isActive = this.isActive(...);
}
});<Routes onActiveStateChange/> -> <Routes onChange />
// 0.7.x
<Routes onActiveStateChange={fn} />
function fn(nextState) {}
// 0.9.x
<Routes onChange={fn} />
function fn() {
// no arguments
// `this` is the routes instance
// here are some useful methods to get at the data you probably need
this.getCurrentPath();
this.getActiveRoutes();
this.getActiveParams();
this.getActiveQuery();
}. in params support
. used to be a delimiter like /, but now its a valid character in
your params.
transition.retry()
transition.retry() used to use transitionTo, creating a new history
entry, it now uses replaceWith.
// 0.7.x
React.createClass({
login: function () {
// ...
transition.retry();
}
});
// 0.9.x
React.createClass({
mixins: [Navigation],
login: function () {
// ...
this.transitionTo(transition.path);
}
});Returning promises from transition hooks
Transition hooks are now sync, unless you opt-in to async withtransition.wait(promise).
// 0.7.x
React.createClass({
statics: {
willTransitionTo: function (transition) {
return somePromise();
}
}
});
// 0.9.x
React.createClass({
statics: {
willTransitionTo: function (transition) {
transition.wait(somePromise());
}
}
});preserveScrollPosition -> scrollBehavior
preserveScrollPosition was totally broken and should have been namedperverseScrollPosition.
There are now three scroll behaviors you can use:
'browser''scrollToTop''none'
browser is the default, and imitates what browsers do in a typical
page reload scenario (preserves scroll positions when using the back
button, scrolls up when you come to a new page, etc.) Also, you can no
longer specify scroll behavior per <Route/> anymore, only <Routes/>
<Routes scrollBehavior="scrollToTop"/>
RouteStore
This was not a public module, but we know some people were using it.
It's gone now. We have made getting at the current routes incredibly
convenient now with additions to the ActiveState mixin.
Router.transitionTo, replaceWith, goBack
These methods have been moved to mixins.
var Router = require('react-router');
// 0.7.x
React.createClass({
whenever: function () {
Router.transitionTo('something');
Router.replaceWith('something');
Router.goBack();
}
});
// 0.9.x
var Navigation = Router.Navigation;
React.createClass({
mixins: [Navigation],
whenever: function () {
this.transitionTo('something');
this.replaceWith('something');
this.goBack();
}
});These were removed, there is no upgrade path in 0.9.0 but we will have
something soon. These weren't intended to be used.
ActiveState lifecycle method updateActiveState removed
We didn't actually need this. Just use this.isActive(to, params, query).
AsyncState mixin removed
There is no upgrade path. Just use comoponentDidMount to request
state. This was some groundwork for server-side rendering but we are
going a different direction now (using props passed in to route
handlers) so we've removed it.
Changes
onChange event to Routes
AsyncState
<Routes onTransitionError><Routes onAbortedTransition>Navigation mixin for components that need to modify the URL
CurrentPath mixin for components that need to know the current URL path
getActiveRoutes, getActiveParams, and getActiveQuery methods to ActiveState mixin
Awkward updateActiveState callback from ActiveState mixin
Router.PathState (use Router.CurrentPath instead)
Router.Transitions (use Router.Navigation instead)
Router.RouteLookup (because it was useless)
<Routes scrollBehavior="browser">alias of "imitateBrowser"<Routes fixedPath>=><Routes initialPath>will be useful for SSR
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.