'How do I go back one page and refresh it using useNavigate?
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)
Lets say this is my code:
import { useNavigate } from 'react-router-dom';
function YourApp() {
const navigate = useNavigate();
return (
<>
<button onClick={() => navigate(-1)}>go back</button>
</>
);
}
Solution 1:[1]
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().
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Liad Dadon |
