First you have to import the useLocation hook
import { useLocation } from "react-router-dom";
then set
const location = useLocation();
now you can use the location object which has the following properties: key, pathname, search, hash, state
{
key: 'ac3df4', // not with HashHistory!
pathname: '/somewhere',
search: '?some=search-string',
hash: '#howdy',
state: undefined
}
* Be the first to Make Comment