React Router V4:如何以编程方式导航到上次访问的页面

React Router V4: how to programatically navigate to last visited page

使用react-router V4,如何以编程方式导航到上次访问的页面?

下面的代码听起来可以吗?

this.props.history.push(this.props.history[this.props.history.length - 1])

使用这个:

this.props.history.goBack();

您也可以使用 go(n):

this.props.history.go(-1);

检查DOC