how to listen for route change in react-router-dom v6

From documentation (https://reactrouter.com/en/main/hooks/use-location), use this hook

let location = useLocation();

React.useEffect(() => {
  ga('send', 'pageview');
}, [location]);

Leave a Comment