alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

How to use useLocation hook of in React Router DOM v6 ?

How to use useLocation hook of in React Router DOM v6 ?

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
}

128 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online