@@ -37,15 +37,13 @@ export default function createConnect(React) {
37
37
const { Component, PropTypes } = React ;
38
38
const storeShape = createStoreShape ( PropTypes ) ;
39
39
40
- return function connect (
41
- mapStateToProps = defaultMapStateToProps ,
42
- actionCreatorsOrMapDispatchToProps = defaultMapDispatchToProps ,
43
- mergeProps = defaultMergeProps
44
- ) {
45
- const shouldSubscribe = mapStateToProps !== defaultMapStateToProps ;
46
- const mapDispatchToProps = isPlainObject ( actionCreatorsOrMapDispatchToProps ) ?
47
- wrapActionCreators ( actionCreatorsOrMapDispatchToProps ) :
48
- actionCreatorsOrMapDispatchToProps ;
40
+ return function connect ( mapStateToProps , mapDispatchToProps , mergeProps ) {
41
+ const shouldSubscribe = Boolean ( mapStateToProps ) ;
42
+ const finalMapStateToProps = mapStateToProps || defaultMapStateToProps ;
43
+ const finalMapDispatchToProps = isPlainObject ( mapDispatchToProps ) ?
44
+ wrapActionCreators ( mapDispatchToProps ) :
45
+ mapDispatchToProps || defaultMapDispatchToProps ;
46
+ const finalMergeProps = mergeProps || defaultMergeProps ;
49
47
50
48
// Helps track hot reloading.
51
49
const version = nextVersion ++ ;
@@ -127,7 +125,7 @@ export default function createConnect(React) {
127
125
128
126
mapState ( props = this . props , context = this . context ) {
129
127
const state = context . store . getState ( ) ;
130
- const stateProps = mapStateToProps ( state ) ;
128
+ const stateProps = finalMapStateToProps ( state ) ;
131
129
132
130
invariant (
133
131
isPlainObject ( stateProps ) ,
@@ -140,7 +138,7 @@ export default function createConnect(React) {
140
138
141
139
mapDispatch ( context = this . context ) {
142
140
const { dispatch } = context . store ;
143
- const dispatchProps = mapDispatchToProps ( dispatch ) ;
141
+ const dispatchProps = finalMapDispatchToProps ( dispatch ) ;
144
142
145
143
invariant (
146
144
isPlainObject ( dispatchProps ) ,
@@ -153,7 +151,7 @@ export default function createConnect(React) {
153
151
154
152
merge ( props = this . props , state = this . state ) {
155
153
const { stateProps, dispatchProps } = state ;
156
- const merged = mergeProps ( stateProps , dispatchProps , props ) ;
154
+ const merged = finalMergeProps ( stateProps , dispatchProps , props ) ;
157
155
158
156
invariant (
159
157
isPlainObject ( merged ) ,
0 commit comments