react-router
8.5.1 · 27 Oct 2026MIT80.2M / weekRepositorynpmAtom feed
0.13.6 is the newest release of 0.6.x.
In short
2 new11 changed
Release note
Path Matching
Paths that start with / are absolute and work exactly as they used to.
Paths that don't start with / are now relative, meaning they extend
their parent route.
Simply add / in front of all your paths to keep things working.
<!-- 0.5.x --> <Route path="/foo"> <Route path="bar"/> </Route> <!-- 0.6.x --> <Route path="/foo"> <Route path="/bar"/> </Route>
Though, you may want to embrace this new feature:
<!-- 0.5.x --> <Route path="/course/:courseId"> <Route path="/course/:courseId/assignments"/> <Route path="/course/:courseId/announcements"/> </Route> <!-- 0.6.x --> <Route path="/course/:courseId"> <Route path="assignments"/> <Route path="announcements"/> </Route>
Also . is no longer matched in dynamic segments.
<!-- 0.5.x --> <Route path="/file/:filename" /> <!-- 0.6.x --> <Route path="/file/:filename.?:ext?" /> <!-- or for a looser match to allow for multiple `.` note that the data will be available on `this.props.params.splat` instead of `this.props.params.filename` --> <Route path="/file/*" />
Link params
Links should now pass their params in the params property, though the
old behavior will still work, you should update your code soon because
it will be removed by v1.0
// 0.5.x
<Link to="user" userId="123"/>
// 0.6.x
<Link to="user" params={{userId: "123"}}/>Dynamic Segments, keys, and lifecycle methods
If you have dynamic segments and are depending on getInitialState,componentWillMount, or componentDidMount to fire between transitions
to the same route--like users/123 and users/456--then you have two
options:
Add
addHandlerKey={true}to your route and keep the previous
behavior (but lose out on performance), orImplement
componentWillReceiveProps.
// 0.5.x
<Route handler={User} path="/user/:userId"/>
// 0.6.x
<Route handler={User} path="/user/:userId" addHandlerKey={true} />
// 0.5.x
var User = React.createClass({
getInitialState: function () {
return {
user: getUser(this.props.params.userId);
}
}
});
// 0.6.x
var User = React.createClass({
getInitialState: function () {
return this.getState();
},
componentWillReceiveProps: function (newProps) {
this.setState(this.getState(newProps));
},
getState: function (props) {
props = props || this.props;
return {
user: getUser(props.params.userId)
};
}
});Changes
Query argument to willTransitionTo
Window scrolling
Default
<Redirect from>to *Paths to inherit parents
<DefaultRoute name>Using HashLocation without a preceeding /
<NotFoundRoute>Path matching algorithm
location="disabled"
<Link/>s to take params propertyHandler keys to be optional
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.