Skip to content

Commit 0ed2860

Browse files
committed
Fixed buf and updated docs
1 parent f8bc228 commit 0ed2860

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,7 @@ function mapActionToProps(dispatch) {
105105
};
106106
}
107107

108-
function mergeProps(stateProps, actionsProps) {
109-
return {
110-
...stateProps,
111-
...actionsProps,
112-
};
113-
}
114-
115-
export default connect(mapStateToProps, mapActionToProps, mergeProps)(App);
108+
export default connect(mapStateToProps, mapActionToProps)(App);
116109

117110
```
118111

@@ -148,3 +141,10 @@ const mapDispatchToProps = (dispatch) => ({})
148141

149142
export default connect(mapStateToProps, mapDispatchToProps)(Comp)
150143
```
144+
145+
## connect([mapStateToProps], [mapDispatchToProps], [mergeProps])
146+
Connects a Vue component to a Redux store.
147+
### Arguments
148+
* [mapStateToProps(state, [ownAttrs]): stateProps] (__Function__) Subscribes component to Redux store updates. This means that any time the store is updated, mapStateToProps will be called. The results of `mapStateToProps` must be a plain object, which will be merged into the component’s props.
149+
* [mapDispatchToProps(dispatch): dispatchProps] (__Function__) Result must be a plain object
150+
* [mergeProps(stateProps, dispatchProps): props] (__Function__) If specified, it is passed the result of `mapStateToProps()` and `mapDispatchToProps()`. The plain object you return from it will be passed as props to the wrapped component.

lib/connect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function connect(mapStateToProps, mapActionsToProps, mergeProps) {
9595
var merged = mergeProps(state, actions);
9696
var propNames = Object.keys(merged);
9797

98-
return _extends({}, mergeProps(state, actions), {
98+
return _extends({}, merged, {
9999
vuaReduxPropNames: propNames
100100
});
101101
},
@@ -112,7 +112,7 @@ function connect(mapStateToProps, mapActionsToProps, mergeProps) {
112112
_this.vuaReduxPropNames = propNames;
113113

114114
for (var ii = 0; ii < propNames.length; ii++) {
115-
_this[propNames[ii]] = state[propNames[ii]];
115+
_this[propNames[ii]] = merged[propNames[ii]];
116116
}
117117
});
118118
},

src/connect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default function connect(mapStateToProps, mapActionsToProps, mergeProps)
9494
const propNames = Object.keys(merged);
9595

9696
return {
97-
...mergeProps(state, actions),
97+
...merged,
9898
vuaReduxPropNames: propNames,
9999
};
100100
},
@@ -110,7 +110,7 @@ export default function connect(mapStateToProps, mapActionsToProps, mergeProps)
110110
this.vuaReduxPropNames = propNames;
111111

112112
for (let ii = 0; ii < propNames.length; ii++) {
113-
this[propNames[ii]] = state[propNames[ii]];
113+
this[propNames[ii]] = merged[propNames[ii]];
114114
}
115115
});
116116
},

0 commit comments

Comments
 (0)