@@ -18,10 +18,11 @@ function getDisplayName(WrappedComponent) {
1818 return WrappedComponent . displayName || WrappedComponent . name || 'Component'
1919}
2020
21- function checkStateShape ( stateProps , dispatch ) {
21+ function checkStateShape ( componentDisplayName , stateProps , dispatch ) {
2222 invariant (
2323 isPlainObject ( stateProps ) ,
24- '`%sToProps` must return an object. Instead received %s.' ,
24+ '`%s %sToProps` must return an object. Instead received %s.' ,
25+ componentDisplayName ,
2526 dispatch ? 'mapDispatch' : 'mapState' ,
2627 stateProps
2728 )
@@ -45,11 +46,12 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
4546 // Helps track hot reloading.
4647 const version = nextVersion ++
4748
48- function computeMergedProps ( stateProps , dispatchProps , parentProps ) {
49+ function computeMergedProps ( componentDisplayName , stateProps , dispatchProps , parentProps ) {
4950 const mergedProps = finalMergeProps ( stateProps , dispatchProps , parentProps )
5051 invariant (
5152 isPlainObject ( mergedProps ) ,
52- '`mergeProps` must return an object. Instead received %s.' ,
53+ '`%s mergeProps` must return an object. Instead received %s.' ,
54+ componentDisplayName ,
5355 mergedProps
5456 )
5557 return mergedProps
@@ -88,7 +90,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
8890 this . finalMapStateToProps ( state , props ) :
8991 this . finalMapStateToProps ( state )
9092
91- return checkStateShape ( stateProps )
93+ return checkStateShape ( this . constructor . displayName , stateProps )
9294 }
9395
9496 configureFinalMapState ( store , props ) {
@@ -100,7 +102,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
100102
101103 return isFactory ?
102104 this . computeStateProps ( store , props ) :
103- checkStateShape ( mappedState )
105+ checkStateShape ( this . constructor . displayName , mappedState )
104106 }
105107
106108 computeDispatchProps ( store , props ) {
@@ -113,7 +115,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
113115 this . finalMapDispatchToProps ( dispatch , props ) :
114116 this . finalMapDispatchToProps ( dispatch )
115117
116- return checkStateShape ( dispatchProps , true )
118+ return checkStateShape ( this . constructor . displayName , dispatchProps , true )
117119 }
118120
119121 configureFinalMapDispatch ( store , props ) {
@@ -125,7 +127,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
125127
126128 return isFactory ?
127129 this . computeDispatchProps ( store , props ) :
128- checkStateShape ( mappedDispatch , true )
130+ checkStateShape ( this . constructor . displayName , mappedDispatch , true )
129131 }
130132
131133 updateStatePropsIfNeeded ( ) {
@@ -149,7 +151,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
149151 }
150152
151153 updateMergedPropsIfNeeded ( ) {
152- const nextMergedProps = computeMergedProps ( this . stateProps , this . dispatchProps , this . props )
154+ const nextMergedProps = computeMergedProps ( this . constructor . displayName , this . stateProps , this . dispatchProps , this . props )
153155 if ( this . mergedProps && checkMergedEquals && shallowEqual ( nextMergedProps , this . mergedProps ) ) {
154156 return false
155157 }
0 commit comments