EN
React / react-router - how to see which route we are on?
3
points
In this article, we would like to show you how to see which route we are on in react-router.
Quick solution:
import { useLocation } from 'react-router-dom'
const App = () => {
const location = useLocation();
console.log(location.pathname) // '/'
}