Can anyone please tell me how I can go back to the previous page rather than a specific route?
When using this code:
var BackButton = React.createCla
This is a working BackButton component (React 0.14):
var React = require('react');
var Router = require('react-router');
var History = Router.History;
var BackButton = React.createClass({
mixins: [ History ],
render: function() {
return (
);
}
});
module.exports = BackButton;
You can off course do something like this if there is no history:
function goBack(e) {
if (/* no history */) {
e.preventDefault();
} else {
this.history.goBack();
}
}