[英]why history.push produce 2 objects in history stack, react-router-dom
I am using 'react-router-dom' library.我正在使用“react-router-dom”库。
import { useHistory } from 'react-router-dom';
const App = () => {
window.lib_history = useHistory();
return /*doesnt matter*/;
}
From console I push some page, but in browser history and in library history 2 object appeared.从控制台我推送了一些页面,但在浏览器历史记录和库历史记录中出现了 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??
And as a main problem - user have to click browser back button 2 times to get previous page.作为一个主要问题 - 用户必须单击浏览器后退按钮 2 次才能获得上一页。 Where should I look for problem?
我应该在哪里寻找问题?
There was an Iframe in my project which spoiled history stack of whole browser tab.我的项目中有一个 Iframe 破坏了整个浏览器选项卡的历史堆栈。 Thanks for hints about setting up history, it was helpful also.
感谢您提供有关设置历史记录的提示,这也很有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.