I am using 'react-router-dom' library.
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.
/*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. Where should I look for problem?
There was an Iframe in my project which spoiled history stack of whole browser tab. Thanks for hints about setting up history, it was helpful also.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.