Answers for "clear location state react"

1

clear location state react

const location = useLocation();
const navigate = useNavigate();

const state = location.state;
// Do some stuff with the state
// ...

// Clear the state after
navigate(location.pathname, { replace: true });
Posted by: Guest on March-04-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language