Languages
[Edit]
EN

React / react-router - how to see which route we are on?

3 points
Created by:
Dirask JS Member
3430

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)  // '/'
}

Java conversion

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join