How to store previous location (route) in a constant and pass it through a query param?
I am using React router v5.
In my React (route) component I have a Link
import { Link } from 'react-router-dom';
<Link to={{ pathname: MyPage, search: `?redirectUrl=previous-route` }}>
Go to page
</Link>
I need to pass the previous location route to the next route (MyPage) through the query param redirectUrl.
<Link to={{ pathname: MyPage, search: `?redirectUrl=${<----- My previous route value here}` }}>
Go to page
</Link>
How do I manage that?