Returns the current Location. This can be useful if you'd like to perform some side effect whenever it changes.
import * as React from 'react'import { useLocation } from 'react-router'function SomeComponent() { let location = useLocation() React.useEffect(() => { // Google Analytics ga('send', 'pageview') }, [location]); return ( // ... );} Copy
import * as React from 'react'import { useLocation } from 'react-router'function SomeComponent() { let location = useLocation() React.useEffect(() => { // Google Analytics ga('send', 'pageview') }, [location]); return ( // ... );}
Returns the current Location. This can be useful if you'd like to perform some side effect whenever it changes.