You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api.md
+22-8Lines changed: 22 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,25 +72,39 @@ Instead, it *returns* a new, connected component class, for you to use.
72
72
*[`pure = true`]*(Boolean)*: If true, implements `shouldComponentUpdate` and shallowly compares the result of `mergeProps`, preventing unnecessary updates, assuming that the component is a “pure” component and does not rely on any input or state other than its props and the selected Redux store’s state. *Defaults to `true`.*
73
73
*[`withRef = false`]*(Boolean)*: If true, stores a ref to the wrapped component instance and makes it available via `getWrappedInstance()` method. *Defaults to `false`.*
74
74
75
-
> Note: `ownProps` is passed to `mapStateToProps` and `mapDispatchToProps`only if formal definition of the function contains two mandatory parameters (function length has to be greater or equal 2). For example, functions defined like below won't receive `ownProps` as the second argument.
75
+
> Note: `ownProps`**is not passed** to `mapStateToProps` and `mapDispatchToProps` if formal definition of the function contains one mandatory parameter (function has length 1). For example, function defined like below won't receive `ownProps` as the second argument.
76
76
```javascript
77
-
functionmapStateToProps() {
78
-
console.log(arguments[0]); // state
77
+
functionmapStateToProps(state) {
78
+
console.log(state); // state
79
79
console.log(arguments[1]); // undefined
80
80
}
81
81
```
82
82
```javascript
83
-
constmapStateToProps= (...args) => {
84
-
console.log(arguments[0]); // state
85
-
console.log(arguments[1]); // undefined
83
+
constmapStateToProps= (state, ownProps= {}) => {
84
+
console.log(state); // state
85
+
console.log(ownProps); // undefined
86
86
}
87
87
```
88
+
Functions with no mandatory parameters or two parameters **will receive**`ownProps`.
0 commit comments