Skip to content

Commit 97436ce

Browse files
committed
Fixed buf and updated docs
1 parent f8bc228 commit 97436ce

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function connect(mapStateToProps, mapActionsToProps, mergeProps) {
9292
data: function data() {
9393
var state = getStates(this, mapStateToProps);
9494
var actions = getActions(this, mapActionsToProps);
95-
var merged = mergeProps(state, actions);
95+
var merged = mergeProps(state, actions, {});
9696
var propNames = Object.keys(merged);
9797

9898
return _extends({}, mergeProps(state, actions), {
@@ -107,12 +107,12 @@ function connect(mapStateToProps, mapActionsToProps, mergeProps) {
107107
this.vuaReduxUnsubscribe = store.subscribe(function () {
108108
var state = getStates(_this, mapStateToProps);
109109
var actions = getActions(_this, mapActionsToProps);
110-
var merged = mergeProps(state, actions);
110+
var merged = mergeProps(state, actions, getAttrs(_this));
111111
var propNames = Object.keys(merged);
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
@@ -90,7 +90,7 @@ export default function connect(mapStateToProps, mapActionsToProps, mergeProps)
9090
data() {
9191
const state = getStates(this, mapStateToProps);
9292
const actions = getActions(this, mapActionsToProps);
93-
const merged = mergeProps(state, actions);
93+
const merged = mergeProps(state, actions, {});
9494
const propNames = Object.keys(merged);
9595

9696
return {
@@ -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)