I have the following
class EntityProfile extends React.Component {
constructor(props) {
super(props);
}
render() {
console.log(this.props.location) // This doesn't work
console.log(window.location.hash.split('/')[2], 'this is my id')
return (
<Container fluid>
<Row>
<span>hiiii</span>
<span>{this.props.location}</span>
</Row>
</Container>
);
}
}
And they're all within a HashRouter, there is one route in specific that looks like so:
<Route path="/foo/:id">
<FooBar/>
</Route>
And I want to get the "id" from that. I read that you can use this.props.location that appears to be undefined, I could get it using window.location.hash.split('/')[2] but that seems a bit dodgy. My uri looks like so: http://localhost:5000/#/foo/1, so in this case I would like to get 1. What am I doing wrong with he location value?