On my SideMenuNavigation component where I have the <Route>
codes, I need to access the value of this.props.location.pathname
. Unfortunately, I'm getting undefined
.
class SideNavigation extends React.Component {
componentDidMount() {
console.log(this.props.location.pathname); // undefined
}
render() {
return(
<Router>
<Route exact path="/" component={Dashboard}/>
</Router>
)
}
}
/* */
In my Dashboard component, I can acess this.props.location.pathname
successfully. Unforunately, I don't need it from this component. I need the value in the SideMenuNavigation
component.