1import { useHistory } from "react-router-dom";
2
3export const Item = () => {
4 let history = useHistory();
5 return (
6 <>
7 <button onClick={() => history.goBack()}>Back</button>
8 </>
9 );
10};
11
1const BrowserHistory = require('react-router/lib/BrowserHistory').default;
2
3const App = React.createClass({
4 render: () => {
5 return (
6 <div><button onClick={BrowserHistory.goBack}>Go Back</button></div>
7 );
8 }
9});
10
11React.render((
12 <Router history={BrowserHistory}>
13 <Route path="/" component={App} />
14 </Router>
15), document.body);
16