Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #clear #location #state #react
ADD COMMENT
Topic
Name
7+6 =