@@ -37,15 +37,13 @@ export default function createConnect(React) {
3737 const { Component, PropTypes } = React ;
3838 const storeShape = createStoreShape ( PropTypes ) ;
3939
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 ;
4947
5048 // Helps track hot reloading.
5149 const version = nextVersion ++ ;
@@ -127,7 +125,7 @@ export default function createConnect(React) {
127125
128126 mapState ( props = this . props , context = this . context ) {
129127 const state = context . store . getState ( ) ;
130- const stateProps = mapStateToProps ( state ) ;
128+ const stateProps = finalMapStateToProps ( state ) ;
131129
132130 invariant (
133131 isPlainObject ( stateProps ) ,
@@ -140,7 +138,7 @@ export default function createConnect(React) {
140138
141139 mapDispatch ( context = this . context ) {
142140 const { dispatch } = context . store ;
143- const dispatchProps = mapDispatchToProps ( dispatch ) ;
141+ const dispatchProps = finalMapDispatchToProps ( dispatch ) ;
144142
145143 invariant (
146144 isPlainObject ( dispatchProps ) ,
@@ -153,7 +151,7 @@ export default function createConnect(React) {
153151
154152 merge ( props = this . props , state = this . state ) {
155153 const { stateProps, dispatchProps } = state ;
156- const merged = mergeProps ( stateProps , dispatchProps , props ) ;
154+ const merged = finalMergeProps ( stateProps , dispatchProps , props ) ;
157155
158156 invariant (
159157 isPlainObject ( merged ) ,
0 commit comments