0 votes
in ReactJS by

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

1 Answer

0 votes
by

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.

Related questions

0 votes
asked Nov 30, 2023 in Linux by JackTerrance
0 votes
asked Oct 24, 2023 in JavaScript by DavidAnderson
...