UNPKG

@25sprout/react-starter

Version:

25sprout web starter with React

17 lines (12 loc) 356 B
import { useState, useEffect } from 'react'; const useLocation = history => { const [location, setLocation] = useState(history.location); useEffect(() => { const unlisten = history.listen(({ location: newLocation }) => { setLocation(newLocation); }); return () => unlisten(); }, [history]); return location; }; export default useLocation;