Answer the question
In order to leave comments, you need to log in
How to know history.length (stack) in react-router-dom 6?
Good afternoon! Tell me how to implement such a function on react-router-dom v6 ?
After all, the history object is gone in version 6, and I can’t find the ifnu in the dock, how to find the history-stack
export const closeModal = (
history: H.History<unknown>,
path: string,
) => {
// history.length <= 2 ? history.push(`/${path}`) : history.goBack();
};
Answer the question
In order to leave comments, you need to log in
Yes, there is no way to know. History refers to a browser tab, not to your application. A person could walk through other sites in this tab, and then download you, then the story will already be long, because it is general.
Once I had to get inside the history, I had to file my own implementation of the History interface, connect it to window.history through events, and stick it in the Router instead of the standard BrowserHistory
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question