alan89757 / react-router-analysis

react-router使用与源码分析
MIT License
0 stars 0 forks source link

React-Router怎么获取历史对象? #1

Open alan89757 opened 3 years ago

alan89757 commented 3 years ago

1.如果React >= 16.8 时可以使用 React Router中提供的Hooks

import { useHistory } from "react-router-dom";
let history = useHistory();

2.使用this.props.history获取历史对象

let history = this.props.history;