useLocation
declare function useLocation<TLocationState>(): Location<TLocationState>;
interface Location<S = LocationState> {
pathname: string;
search: string;
state: S;
hash: string;
key?: string;
}
This hook returns the current location object. This can be useful if you'd like to perform some side effect whenever the current location changes.
import { useLocation } from '@archibald/core';
function App() {
const location = useLocation();
useEffect(() => {
// Google Analytics
ga('send', 'pageview');
}, [location]);
return;
}