I want to go back one page and refresh it because I need a list to be updated and it doesn't do it when I'm just using the navigate(-1)
Code for example:
import { useNavigate } from 'react-router-dom';
function YourApp() {
const navigate = useNavigate();
return (
<>
<button onClick={() => navigate(-1)}>go back</button>
</>
);
}
I was able to solve this partly.
To be able to refresh the list I wanted I used Redux and its useSelector() function.
The refresh page part is not possible yet because its not implemented into the navigator.
Btw: The functionality I was after is the equivalent of doing window.location.reload().
If you're using react-router v6
import { useNavigate } from "react-router-dom";
const navigate = useNavigate();
const refreshPage = () => {
navigate(0);
}