Answers for "how get route name in react js"

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 native get route name

import { useNavigation, useRoute } from '@react-navigation/native';
const Route = useRoute();

console.log(Route);
// Object {
//  "key": "Home-rRl8EIxLOOm9rqd2N6RSZ",
//  "name": "Home",
//  "params": undefined,
// }
Posted by: Guest on August-09-2021

Code answers related to "how get route name in react js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language