Answers for "js how to detect the current route path in react"

0

how to know the current route in react class component

/*For class based components*/
import { withRouter } from 'react-router-dom';

class SomeComponent extends Component {
  render() {
    console.log(this.props.location)
    console.log(this.props.location.pathname)
    console.log(this.props.location.match)
    return <div>Something</div>
  }
}

export default withRouter(SomeComponent)
Posted by: Guest on August-09-2021

Code answers related to "js how to detect the current route path in react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language