Skip to content

Commit

Permalink
Add note about passing ownProps functions
Browse files Browse the repository at this point in the history
  • Loading branch information
erykpiast committed Jun 24, 2016
1 parent 8b2843a commit 2eb1919
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ Instead, it *returns* a new, connected component class, for you to use.
* [`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`.*
* [`withRef = false`] *(Boolean)*: If true, stores a ref to the wrapped component instance and makes it available via `getWrappedInstance()` method. *Defaults to `false`.*

> 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.
```javascript
function mapStateToProps() {
console.log(arguments[0]); // state
console.log(arguments[1]); // undefined
}
```
```javascript
const mapStateToProps = (...args) => {
console.log(arguments[0]); // state
console.log(arguments[1]); // undefined
}
```
```javascript
const mapStateToProps = (state, ownProps = {}) => {
console.log(state); // state
console.log(ownProps); // undefined
}
```

#### Returns

A React component class that injects state and action creators into your component according to the specified options.
Expand Down

0 comments on commit 2eb1919

Please sign in to comment.