I am reading the API on react-redux and looking at one of Redux' github examples: Redux todo app
One of the containers, FilterLink
, has mapDispatchToProps
(and mapStateToProps
) to accept two arguments, one of them being ownprops.
const mapDispatchToProps = (dispatch, ownProps) => ({
onClick: () => {
dispatch(setVisibilityFilter(ownProps.filter))
}
})
The API docs says:
"If your mapStateToProps function is declared as taking two parameters, it will be called with the store state as the first parameter and the props passed to the connected component as the second parameter, and will also be re-invoked whenever the connected component receives new props as determined by shallow equality comparisons. (The second parameter is normally referred to as ownProps by convention.)"
I still can't fully grasp what it does. Can someone explain what ownProps
does with a different example?