0

this is probably the second code-related question I will be asking on this platform. I am working with React Js.

I imported useLocation hook from 'react-router-dom" and defined location as follows

location = useLocation()

How can I detect the current page and the next page I navigated to when I make a click action?

<location.pathname> detects the current page pathname. For example, Assuming I am on page 1 and I navigate to page 2 when I make a click action, While on page 2, how can I detect that I navigated from page 1 to page 2?

  • Does this answer your question? [Detect Route Change with react-router](https://stackoverflow.com/questions/45373742/detect-route-change-with-react-router) – imjared Oct 13 '22 at 16:05

0 Answers0