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:
xxxxxxxxxx
1
import { useLocation } from 'react-router-dom'
2
3
const App = () => {
4
const location = useLocation();
5
console.log(location.pathname) // '/'
6
}