@@ -39,11 +39,22 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
39
39
mapDispatchToProps || defaultMapDispatchToProps
40
40
41
41
const finalMergeProps = mergeProps || defaultMergeProps
42
+ const checkMergedEquals = finalMergeProps !== defaultMergeProps
42
43
const { pure = true , withRef = false } = options
43
44
44
45
// Helps track hot reloading.
45
46
const version = nextVersion ++
46
47
48
+ function computeMergedProps ( stateProps , dispatchProps , parentProps ) {
49
+ const mergedProps = finalMergeProps ( stateProps , dispatchProps , parentProps )
50
+ invariant (
51
+ isPlainObject ( mergedProps ) ,
52
+ '`mergeProps` must return an object. Instead received %s.' ,
53
+ mergedProps
54
+ )
55
+ return mergedProps
56
+ }
57
+
47
58
return function wrapWithConnect ( WrappedComponent ) {
48
59
class Connect extends Component {
49
60
shouldComponentUpdate ( ) {
@@ -106,16 +117,6 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
106
117
return isFactory ? this . computeDispatchProps ( store , props ) : checkStateShape ( mappedDispatch , true )
107
118
}
108
119
109
- computeMergedProps ( stateProps , dispatchProps , parentProps ) {
110
- const mergedProps = finalMergeProps ( stateProps , dispatchProps , parentProps )
111
- invariant (
112
- isPlainObject ( mergedProps ) ,
113
- '`mergeProps` must return an object. Instead received %s.' ,
114
- mergedProps
115
- )
116
- return mergedProps
117
- }
118
-
119
120
updateStatePropsIfNeeded ( ) {
120
121
const nextStateProps = this . computeStateProps ( this . store , this . props )
121
122
if ( this . stateProps && shallowEqual ( nextStateProps , this . stateProps ) ) {
@@ -137,8 +138,8 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
137
138
}
138
139
139
140
updateMergedPropsIfNeeded ( ) {
140
- const nextMergedProps = this . computeMergedProps ( this . stateProps , this . dispatchProps , this . props )
141
- if ( this . mergedProps && shallowEqual ( nextMergedProps , this . mergedProps ) ) {
141
+ const nextMergedProps = computeMergedProps ( this . stateProps , this . dispatchProps , this . props )
142
+ if ( this . mergedProps && checkMergedEquals && shallowEqual ( nextMergedProps , this . mergedProps ) ) {
142
143
return false
143
144
}
144
145
0 commit comments