0

Let's say I'm in Page A(/path-a) and I go to page B(/path-b). Afterwards, I click the "previous page" button in the browser.

In this case, how should I get the value of /path-b in PageA.tsx?

Update
I am using react-router-dom

CCCC
  • 5,665
  • 4
  • 41
  • 88

1 Answers1

0
  • Assuming you want a vanilla JS solution:

    You can use document.referrer. This will give you the url you come from, in the new page.

    For more information you can see this link

  • Assuming you want a React Router Dom solution:

    This SO's answer from another post explains really well how to do it

Hector
  • 56
  • 1
  • 3