This example code makes no sense to me
var Navigation = require('react-router').Navigation;
React.createClass({
mixins: [Navigation],
whenever: function () {
this.transitionTo('something');
this.replaceWith('something');
this.goBack();
}
});
From reading the docs I just don't understand how this makes any sense. Could you maybe explain a bit more what's happening here? Thanks :)
Looks like someone was too lazy to come up with a real example :smile:
It just tells you that with Navigation mixin you get to use this three methods on the component instance. Usually, you'd call them from a handler method, like a click handler. You should only call one of those at a time though.
Perhaps this makes more sense:
var Navigation = require('react-router').Navigation;
React.createClass({
mixins: [Navigation],
render: function() {
return (
<div onClick={() => this.transitionTo('foo')}>Go to foo</div>
<div onClick={() => this.replaceWith('bar')}>Go to bar without creating a new history entry</div>
<div onClick={() => this.goBack()}>Go back</div>
);
}
});
Phew I thought I was loosing it. Your example is how I understood the text :smile:
Feel free to update the example, sometimes its 1:00am and I've been writing docs/upgrade guides for hours at that point and don't give it enough thought :)