Skip to content

Commit e0ae39a

Browse files
committed
Revert from object spread notation to Object.assign in documentation
1 parent c53ff52 commit e0ae39a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Connects a React component to a Redux store.
230230

231231
* [`mapDispatchToProps(dispatch, [ownProps]): dispatchProps`] \(*Object* or *Function*): If an object is passed, each function inside it will be assumed to be a Redux action creator. An object with the same function names, but bound to a Redux store, will be merged into the component’s props. If a function is passed, it will be given `dispatch`. It’s up to you to return an object that somehow uses `dispatch` to bind action creators in your own way. (Tip: you may use [`bindActionCreators()`](http://gaearon.github.io/redux/docs/api/bindActionCreators.html) helper from Redux.) If you omit it, the default implementation just injects `dispatch` into your component’s props. If `ownProps` is specified as a second argument then `mapDispatchToProps` will be re-invoked whenever the component receives new props.
232232

233-
* [`mergeProps(stateProps, dispatchProps, ownProps): props`] \(*Function*): If specified, it is passed the result of `mapStateToProps()`, `mapDispatchToProps()`, and the parent `props`. The plain object you return from it will be passed as props to the wrapped component. You may specify this function to select a slice of the state based on props, or to bind action creators to a particular variable from props. If you omit it, `{ ...ownProps, ...stateProps, ...dispatchProps }` is used by default.
233+
* [`mergeProps(stateProps, dispatchProps, ownProps): props`] \(*Function*): If specified, it is passed the result of `mapStateToProps()`, `mapDispatchToProps()`, and the parent `props`. The plain object you return from it will be passed as props to the wrapped component. You may specify this function to select a slice of the state based on props, or to bind action creators to a particular variable from props. If you omit it, `Object.assign({}, ownProps, stateProps, dispatchProps)` is used by default.
234234

235235
#### Returns
236236

@@ -347,7 +347,7 @@ function mapStateToProps(state) {
347347

348348
function mapDispatchToProps(dispatch) {
349349
return {
350-
actions: bindActionCreators({ ...todoActionCreators, ...counterActionCreators }, dispatch)
350+
actions: bindActionCreators(Object.assign({}, todoActionCreators, counterActionCreators), dispatch)
351351
};
352352
}
353353

@@ -366,7 +366,7 @@ function mapStateToProps(state) {
366366
}
367367

368368
function mapDispatchToProps(dispatch) {
369-
return bindActionCreators({ ...todoActionCreators, ...counterActionCreators}, dispatch);
369+
return bindActionCreators(Object.assign({}, todoActionCreators, counterActionCreators), dispatch);
370370
}
371371

372372
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);
@@ -394,11 +394,10 @@ function mapStateToProps(state) {
394394
}
395395

396396
function mergeProps(stateProps, dispatchProps, ownProps) {
397-
return {
398-
...ownProps,
397+
return Object.assign({}, ownProps, {
399398
todos: stateProps.todos[ownProps.userId],
400399
addTodo: (text) => dispatchProps.addTodo(ownProps.userId, text)
401-
};
400+
});
402401
}
403402

404403
export default connect(mapStateToProps, actionCreators, mergeProps)(TodoApp);

0 commit comments

Comments
 (0)