I'm using react-router-redux (https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux)
installed with
npm install --save react-router-redux@next
implemented like so:
<Route path='/resource/:id' component={Resource}/>
I'm trying to access the parameter for the id in the container, like so:
const mapStateToProps = (state, ownProps) => {
console.log(ownProps)
return {...state.resource, id: ownProps.params.id}
}
As shown in the react-router-redux docs.
I'm getting an error stating that ownProps.params is undefined however. So this works:
const mapStateToProps = (state, ownProps) => {
return {...state.resource, id: ownProps.match.params.id}
}
When I log ownProps, however, I find that ownProps.match.params.id contains the id I require.
Is this a change in implementation or have I implemented the route wrong? Thanks
Route
s have always been passed three props,match
,location
, andhistory
. – Expulsive