I want to check for cookies every time a user gets redirected to a different Route. What would be the most conventional way to do this besides coding the function each time at the top of the main component which each Route loads?
CodePudding user response:
You can use the useLocation
and the useEffect
hook:
function App() {
let location = useLocation();
useEffect(() => {
//do your stuff
}, [location]);
return (
// ...
);
}