Skip to content

Commit

Permalink
fix(docs): remove mapDispatchToProps untruthy use case (#1364)
Browse files Browse the repository at this point in the history
Tried every form of `mapDispatchToProps`
`dispatch` is never missing from `props`
  • Loading branch information
iamandrewluca authored and timdorr committed Jul 26, 2019
1 parent 8a1bb58 commit ae6f033
Showing 1 changed file with 0 additions and 16 deletions.
Expand Up @@ -254,22 +254,6 @@ connect(
)(Counter)
```

### Manually Injecting `dispatch`

If the `mapDispatchToProps` argument is supplied, the component will no longer receive the default `dispatch`. You may bring it back by adding it manually to the return of your `mapDispatchToProps`, although most of the time you shouldn’t need to do this:

```js
import { bindActionCreators } from 'redux'
// ...

function mapDispatchToProps(dispatch) {
return {
dispatch,
...bindActionCreators({ increment, decrement, reset }, dispatch)
}
}
```

## Defining `mapDispatchToProps` As An Object

You’ve seen that the setup for dispatching Redux actions in a React component follows a very similar process: define an action creator, wrap it in another function that looks like `(…args) => dispatch(actionCreator(…args))`, and pass that wrapper function as a prop to your component.
Expand Down

0 comments on commit ae6f033

Please sign in to comment.