Answers for "get route path react"

3

react get route path

import { useLocation } from 'react-router-dom'

function HeaderView() {
  const location = useLocation();
  console.log(location.pathname);
  return <span>Path : {location.pathname}</span>
}
Posted by: Guest on May-09-2021
0

React route path exact

<Route exact path="/">
  <Home />
</Route>

# The exact prop above tells the Router component to match the path exactly. If you don't add the exact prop on the / path, it will match with all the routes starting with a / including /about.
Posted by: Guest on May-23-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language