Add further explanation of ownProps in mstp (#26455)
* Add further explanation of ownProps in mstp * Added syntax highlighting
This commit is contained in:
committed by
Manish Giri
parent
94ba6fc6d8
commit
2f342d0dc4
@ -145,6 +145,15 @@ The example above demonstrates how the base App component is setup and how it wi
|
|||||||
|
|
||||||
Also how to dispatch a defined action from the component which will be passed down to the store and make the changes on the application reducer.
|
Also how to dispatch a defined action from the component which will be passed down to the store and make the changes on the application reducer.
|
||||||
|
|
||||||
|
`mapStateToProps` takes a second argument, `ownProps`, which are the props of the component. This can be useful for mapping props from the store based on the component's exisiting props. For example
|
||||||
|
```javascript
|
||||||
|
const mapStateToProps = (state, ownProps) => {
|
||||||
|
if (ownProps.userId) {
|
||||||
|
return { friends: state.friends[ownProps.userId }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Declaration of the Application Actions
|
## Declaration of the Application Actions
|
||||||
|
|
||||||
The following file:
|
The following file:
|
||||||
|
Reference in New Issue
Block a user