Get previous route location and detect usage of the back button #10886
Unanswered
slavafomin
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
Consider, I have a route component that when activated needs to access the data about the previous location (pathname) and needs to know whether the back button was actually used to navigate to it (or a
navigate(-1)
call). What would be the most effective way to implement this with react router?I've tried various approaches, but nothing seems to work reasonably well. One of the problems is the order of execution of react hooks that I use to track the location change and the hooks used in rendering the component, sometimes component is rendered before the state is updated so the incorrect data is getting used.
Beta Was this translation helpful? Give feedback.
All reactions