@@ -18,17 +18,6 @@ function getDisplayName(WrappedComponent) {
18
18
return WrappedComponent . displayName || WrappedComponent . name || 'Component'
19
19
}
20
20
21
- function checkStateShape ( componentDisplayName , props , methodName ) {
22
- invariant (
23
- isPlainObject ( props ) ,
24
- '`%s %s` must return an object. Instead received %s.' ,
25
- componentDisplayName ,
26
- methodName ,
27
- props
28
- )
29
- return props
30
- }
31
-
32
21
// Helps track hot reloading.
33
22
let nextVersion = 0
34
23
@@ -46,14 +35,25 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
46
35
// Helps track hot reloading.
47
36
const version = nextVersion ++
48
37
49
- function computeMergedProps ( componentDisplayName , stateProps , dispatchProps , parentProps ) {
50
- const mergedProps = finalMergeProps ( stateProps , dispatchProps , parentProps )
51
- return checkStateShape ( componentDisplayName , mergedProps , 'mergeProps' )
52
- }
53
-
54
38
return function wrapWithConnect ( WrappedComponent ) {
55
39
const connectDisplayName = `Connect(${ getDisplayName ( WrappedComponent ) } )`
56
40
41
+ function checkStateShape ( props , methodName ) {
42
+ invariant (
43
+ isPlainObject ( props ) ,
44
+ '`%s %s` must return an object. Instead received %s.' ,
45
+ connectDisplayName ,
46
+ methodName ,
47
+ props
48
+ )
49
+ return props
50
+ }
51
+
52
+ function computeMergedProps ( stateProps , dispatchProps , parentProps ) {
53
+ const mergedProps = finalMergeProps ( stateProps , dispatchProps , parentProps )
54
+ return checkStateShape ( mergedProps , 'mergeProps' )
55
+ }
56
+
57
57
class Connect extends Component {
58
58
shouldComponentUpdate ( ) {
59
59
return ! pure || this . haveOwnPropsChanged || this . hasStoreStateChanged
@@ -86,7 +86,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
86
86
this . finalMapStateToProps ( state , props ) :
87
87
this . finalMapStateToProps ( state )
88
88
89
- return checkStateShape ( connectDisplayName , stateProps , 'mapStateToProps' )
89
+ return checkStateShape ( stateProps , 'mapStateToProps' )
90
90
}
91
91
92
92
configureFinalMapState ( store , props ) {
@@ -98,7 +98,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
98
98
99
99
return isFactory ?
100
100
this . computeStateProps ( store , props ) :
101
- checkStateShape ( connectDisplayName , mappedState , 'mapStateToProps' )
101
+ checkStateShape ( mappedState , 'mapStateToProps' )
102
102
}
103
103
104
104
computeDispatchProps ( store , props ) {
@@ -111,7 +111,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
111
111
this . finalMapDispatchToProps ( dispatch , props ) :
112
112
this . finalMapDispatchToProps ( dispatch )
113
113
114
- return checkStateShape ( connectDisplayName , dispatchProps , 'mapDispatchToProps' )
114
+ return checkStateShape ( dispatchProps , 'mapDispatchToProps' )
115
115
}
116
116
117
117
configureFinalMapDispatch ( store , props ) {
@@ -123,7 +123,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
123
123
124
124
return isFactory ?
125
125
this . computeDispatchProps ( store , props ) :
126
- checkStateShape ( connectDisplayName , mappedDispatch , 'mapDispatchToProps' )
126
+ checkStateShape ( mappedDispatch , 'mapDispatchToProps' )
127
127
}
128
128
129
129
updateStatePropsIfNeeded ( ) {
@@ -147,7 +147,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
147
147
}
148
148
149
149
updateMergedPropsIfNeeded ( ) {
150
- const nextMergedProps = computeMergedProps ( connectDisplayName , this . stateProps , this . dispatchProps , this . props )
150
+ const nextMergedProps = computeMergedProps ( this . stateProps , this . dispatchProps , this . props )
151
151
if ( this . mergedProps && checkMergedEquals && shallowEqual ( nextMergedProps , this . mergedProps ) ) {
152
152
return false
153
153
}
0 commit comments