![](/img/trans.png)
[英]history.push to /login (on logout) is not working in react-router-dom
[英]why history.push produce 2 objects in history stack, react-router-dom
我正在使用“react-router-dom”庫。
import { useHistory } from 'react-router-dom';
const App = () => {
window.lib_history = useHistory();
return /*doesnt matter*/;
}
從控制台我推送了一些頁面,但在瀏覽器歷史記錄和庫歷史記錄中出現了 2 object。
/*in console*/
console.log(window.history.length, lib_history.length); // return 11 10 <--it is okay
lib_history.push('/page2'); // redirect successfully
console.log(window.history.length, lib_history.length); // return 13 12 < -- why not 12 11??
作為一個主要問題 - 用戶必須單擊瀏覽器后退按鈕 2 次才能獲得上一頁。 我應該在哪里尋找問題?
我的項目中有一個 Iframe 破壞了整個瀏覽器選項卡的歷史堆棧。 感謝您提供有關設置歷史記錄的提示,這也很有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.