I am currently working on react-redux with react-router, and one of my page need to know which page user clicked to direct to this new page.
Is there a way that I can get the information about the url of previous page by react-router?
I am currently working on react-redux with react-router, and one of my page need to know which page user clicked to direct to this new page.
Is there a way that I can get the information about the url of previous page by react-router?
You should be able to save the previous location in the getDerivedStateFromProps method.
static getDerivedStateFromProps(nextProps, prevState) {
if (prevState.location === //your path){
...
}
return null;
};
More info here: https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops