@@ -12,8 +12,6 @@ const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({
1212 ...dispatchProps
1313} ) ;
1414
15- const resetValue = ( _ , key ) => ( { [ key ] : undefined } ) ;
16-
1715function getDisplayName ( Component ) {
1816 return Component . displayName || Component . name || 'Component' ;
1917}
@@ -82,7 +80,7 @@ export default function createConnect(React) {
8280 } ;
8381
8482 shouldComponentUpdate ( nextProps , nextState ) {
85- return ! shallowEqual ( this . state , nextState ) ;
83+ return ! shallowEqual ( this . state . props , nextState . props ) ;
8684 }
8785
8886 constructor ( props , context ) {
@@ -99,7 +97,9 @@ export default function createConnect(React) {
9997
10098 this . stateProps = computeStateProps ( this . store ) ;
10199 this . dispatchProps = computeDispatchProps ( this . store ) ;
102- this . state = this . computeNextState ( ) ;
100+ this . state = {
101+ props : this . computeNextState ( )
102+ } ;
103103 }
104104
105105 recomputeStateProps ( ) {
@@ -132,10 +132,9 @@ export default function createConnect(React) {
132132
133133 recomputeState ( props = this . props ) {
134134 const nextState = this . computeNextState ( props ) ;
135- if ( ! shallowEqual ( nextState , this . state ) ) {
135+ if ( ! shallowEqual ( nextState , this . state . props ) ) {
136136 this . setState ( {
137- ...Object . keys ( this . state ) . reduce ( resetValue , { } ) ,
138- ...nextState
137+ props : nextState
139138 } ) ;
140139 }
141140 }
@@ -185,7 +184,7 @@ export default function createConnect(React) {
185184 render ( ) {
186185 return (
187186 < WrappedComponent ref = 'wrappedInstance'
188- { ...this . state } />
187+ { ...this . state . props } />
189188 ) ;
190189 }
191190 }
0 commit comments