I am facing a problem using mapStateToProps(state, ownProps)
in order to plug query parameters from my URL to the props of my component.
I am trying to use my URL as a searchState
as suggested by Dan Abramov answer in this question : How to sync Redux state and url query params
The problem is, I cam not able to access query params from ownProps
.
My URL is, for example : http://localhost:3000/courses?language=en&page=3 and I would like to access the page number as a prop.
I think ownProps
does not work for query parameters (i.e [...]?language=en&page=3
). I tried this kind of stuff but it does not seem to work :
[...]
console.log(props.pageNumber)
[...]
const mapStateToProps = (state, ownProps) => {
return {
pageNumber: ownProps.match.params.page
}
}
Do you have any idea on how I could access my page number as an ownProp coming from my URL ?
Thanks in advance.