React 項目使用 React-router-dom 4.0 以上版本時使用 HashRouter 怎麼控制 history

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

相關文章
相關標籤/搜索