React 项目使用 React-router-dom 4.0 以上版本时使用 HashRouter 怎么控制 history?

不添加 history 时,来回点击 Link 会在控制台报错如下

Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack

解决方案是安装使用 history 模块

import createBrowserHistory from "history/createBrowserHistory";
const customHistory = createBrowserHistory();

<Router history  = {customHistory} />

注意引入的 HashRouter 改变成 Router