UsEmatch

// React Router v6: 
// hook returns match data about a route 
// at given path relative to current location
import { useMatch } from 'react-router-dom'

function BlogPost() {
 let match = useMatch({ 
   '/blog/:slug', 
   end: true, 
   caseSensitive: true 
 })
 // Do something with the match...
 return <div />
}

// React Router v5
import { useRouteMatch } from 'react-router-dom'

function BlogPost() {
 let match = useRouteMatch({ 
   '/blog/:slug', 
   strict: true, 
   sensitive: true 
 })
 // Do something with the match...
 return <div />
}
Coffee Addict