A mixin for components that need to create URLs and/or initiate transitions to other routes.
Programmatically transition to a new route.
this.transitionTo('user', {id: 10}, {showAge: true});
this.transitionTo('about');
this.transitionTo('/users/10?showAge=true');
this.transitionTo('http://example.com/users/10?showAge=true');
Programmatically replace current route with a new route. Does not add an entry into the browser history.
this.replaceWith('user', {id: 10}, {showAge: true});
this.replaceWith('about');
this.replaceWith('/users/10?showAge=true');
Programmatically go back to the last route and remove the most recent entry from the browser history.
this.goBack();
Creates a URL path to a route.
Creates an href
to a route. Use this along with State
when you
need to build components similar to Link
.
// given a route like this:
// <Route name="user" path="users/:userId"/>
this.makeHref('user', {userId: 123}); // "users/123"
var Navigation = require('react-router').Navigation;
React.createClass({
mixins: [Navigation],
whenever: function () {
this.transitionTo('something');
this.replaceWith('something');
this.goBack();
}
});