@@ -12,8 +12,6 @@ const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({
12
12
...dispatchProps
13
13
} ) ;
14
14
15
- const resetValue = ( _ , key ) => ( { [ key ] : undefined } ) ;
16
-
17
15
function getDisplayName ( Component ) {
18
16
return Component . displayName || Component . name || 'Component' ;
19
17
}
@@ -82,7 +80,7 @@ export default function createConnect(React) {
82
80
} ;
83
81
84
82
shouldComponentUpdate ( nextProps , nextState ) {
85
- return ! shallowEqual ( this . state , nextState ) ;
83
+ return ! shallowEqual ( this . state . props , nextState . props ) ;
86
84
}
87
85
88
86
constructor ( props , context ) {
@@ -99,7 +97,9 @@ export default function createConnect(React) {
99
97
100
98
this . stateProps = computeStateProps ( this . store ) ;
101
99
this . dispatchProps = computeDispatchProps ( this . store ) ;
102
- this . state = this . computeNextState ( ) ;
100
+ this . state = {
101
+ props : this . computeNextState ( )
102
+ } ;
103
103
}
104
104
105
105
recomputeStateProps ( ) {
@@ -132,10 +132,9 @@ export default function createConnect(React) {
132
132
133
133
recomputeState ( props = this . props ) {
134
134
const nextState = this . computeNextState ( props ) ;
135
- if ( ! shallowEqual ( nextState , this . state ) ) {
135
+ if ( ! shallowEqual ( nextState , this . state . props ) ) {
136
136
this . setState ( {
137
- ...Object . keys ( this . state ) . reduce ( resetValue , { } ) ,
138
- ...nextState
137
+ props : nextState
139
138
} ) ;
140
139
}
141
140
}
@@ -185,7 +184,7 @@ export default function createConnect(React) {
185
184
render ( ) {
186
185
return (
187
186
< WrappedComponent ref = 'wrappedInstance'
188
- { ...this . state } />
187
+ { ...this . state . props } />
189
188
) ;
190
189
}
191
190
}
0 commit comments