Skip to content

Commit

Permalink
add important clarification doc removed in #15896 (#15987)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerrad committed Jun 5, 2019
1 parent 3c0b12b commit 705497b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {
// <SaleButton>Start Sale!</SaleButton>
```
_Note:_ It is important that the `mapDispatchToProps` function always
returns an object with the same keys. For example, it should not contain
conditions under which a different value would be returned.
_Parameters_
- _mapDispatchToProps_ `Function`: A function of returning an object of prop names where value is a dispatch-bound action creator, or a function to be called with the component's props and returning an action creator.
Expand Down
4 changes: 4 additions & 0 deletions packages/data/src/components/with-dispatch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ import { useDispatchWithMap } from '../use-dispatch';
* // <SaleButton>Start Sale!</SaleButton>
* ```
*
* _Note:_ It is important that the `mapDispatchToProps` function always
* returns an object with the same keys. For example, it should not contain
* conditions under which a different value would be returned.
*
* @return {Component} Enhanced component with merged dispatcher props.
*/
const withDispatch = ( mapDispatchToProps ) => createHigherOrderComponent(
Expand Down

0 comments on commit 705497b

Please sign in to comment.