react-router go back a page how do you configure history?

前端 未结 21 1305
说谎
说谎 2020-11-30 18:30

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         


        
21条回答
  •  感情败类
    2020-11-30 18:57

    I think you just need to enable BrowserHistory on your router by intializing it like that : .

    Before that, you should require BrowserHistory from 'react-router/lib/BrowserHistory'

    I hope that helps !

    UPDATE : example in ES6

    const BrowserHistory = require('react-router/lib/BrowserHistory').default;
    
    const App = React.createClass({
        render: () => {
            return (
                
    ); } }); React.render(( ), document.body);

提交回复
热议问题