@@ -18,10 +18,11 @@ function getDisplayName(WrappedComponent) {
18
18
return WrappedComponent . displayName || WrappedComponent . name || 'Component'
19
19
}
20
20
21
- function checkStateShape ( stateProps , dispatch ) {
21
+ function checkStateShape ( componentDisplayName , stateProps , dispatch ) {
22
22
invariant (
23
23
isPlainObject ( stateProps ) ,
24
- '`%sToProps` must return an object. Instead received %s.' ,
24
+ '`%s %sToProps` must return an object. Instead received %s.' ,
25
+ componentDisplayName ,
25
26
dispatch ? 'mapDispatch' : 'mapState' ,
26
27
stateProps
27
28
)
@@ -45,11 +46,12 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
45
46
// Helps track hot reloading.
46
47
const version = nextVersion ++
47
48
48
- function computeMergedProps ( stateProps , dispatchProps , parentProps ) {
49
+ function computeMergedProps ( componentDisplayName , stateProps , dispatchProps , parentProps ) {
49
50
const mergedProps = finalMergeProps ( stateProps , dispatchProps , parentProps )
50
51
invariant (
51
52
isPlainObject ( mergedProps ) ,
52
- '`mergeProps` must return an object. Instead received %s.' ,
53
+ '`%s mergeProps` must return an object. Instead received %s.' ,
54
+ componentDisplayName ,
53
55
mergedProps
54
56
)
55
57
return mergedProps
@@ -88,7 +90,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
88
90
this . finalMapStateToProps ( state , props ) :
89
91
this . finalMapStateToProps ( state )
90
92
91
- return checkStateShape ( stateProps )
93
+ return checkStateShape ( this . constructor . displayName , stateProps )
92
94
}
93
95
94
96
configureFinalMapState ( store , props ) {
@@ -100,7 +102,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
100
102
101
103
return isFactory ?
102
104
this . computeStateProps ( store , props ) :
103
- checkStateShape ( mappedState )
105
+ checkStateShape ( this . constructor . displayName , mappedState )
104
106
}
105
107
106
108
computeDispatchProps ( store , props ) {
@@ -113,7 +115,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
113
115
this . finalMapDispatchToProps ( dispatch , props ) :
114
116
this . finalMapDispatchToProps ( dispatch )
115
117
116
- return checkStateShape ( dispatchProps , true )
118
+ return checkStateShape ( this . constructor . displayName , dispatchProps , true )
117
119
}
118
120
119
121
configureFinalMapDispatch ( store , props ) {
@@ -125,7 +127,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
125
127
126
128
return isFactory ?
127
129
this . computeDispatchProps ( store , props ) :
128
- checkStateShape ( mappedDispatch , true )
130
+ checkStateShape ( this . constructor . displayName , mappedDispatch , true )
129
131
}
130
132
131
133
updateStatePropsIfNeeded ( ) {
@@ -149,7 +151,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
149
151
}
150
152
151
153
updateMergedPropsIfNeeded ( ) {
152
- const nextMergedProps = computeMergedProps ( this . stateProps , this . dispatchProps , this . props )
154
+ const nextMergedProps = computeMergedProps ( this . constructor . displayName , this . stateProps , this . dispatchProps , this . props )
153
155
if ( this . mergedProps && checkMergedEquals && shallowEqual ( nextMergedProps , this . mergedProps ) ) {
154
156
return false
155
157
}
0 commit comments