From 2f342d0dc4943cea3db982435e29a453ce40630d Mon Sep 17 00:00:00 2001 From: Aaron Gottlieb Date: Sun, 27 Jan 2019 11:06:47 -0700 Subject: [PATCH] Add further explanation of ownProps in mstp (#26455) * Add further explanation of ownProps in mstp * Added syntax highlighting --- guide/english/redux/tutorial/index.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/guide/english/redux/tutorial/index.md b/guide/english/redux/tutorial/index.md index 6b58caea1e..6e3b7ca0c0 100644 --- a/guide/english/redux/tutorial/index.md +++ b/guide/english/redux/tutorial/index.md @@ -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. +`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 The following file: