What is the use of the `ownProps` parameter in `mapStateToProps()` and `mapDispatchToProps()`?

If the ownProps parameter is specified, React Redux will pass the props that were passed to the component into your connect functions. So, if you use a connected component:

import ConnectedComponent from './containers/ConnectedComponent';
<ConnectedComponent user={'john'} />;

The ownProps inside your mapStateToProps() and mapDispatchToProps() functions will be an object:

{
user: 'john';
}

You can use this object to decide what to return from those functions.


August 21, 2022
232