@@ -110,8 +110,16 @@ export default function createConnect(React) {
110
110
} ;
111
111
}
112
112
113
- recomputeStateProps ( ) {
114
- const nextStateProps = computeStateProps ( this . store , this . props ) ;
113
+ computeNextState ( props = this . props ) {
114
+ return computeNextState (
115
+ this . stateProps ,
116
+ this . dispatchProps ,
117
+ props
118
+ ) ;
119
+ }
120
+
121
+ updateStateProps ( props = this . props ) {
122
+ const nextStateProps = computeStateProps ( this . store , props ) ;
115
123
if ( shallowEqual ( nextStateProps , this . stateProps ) ) {
116
124
return false ;
117
125
}
@@ -120,8 +128,8 @@ export default function createConnect(React) {
120
128
return true ;
121
129
}
122
130
123
- recomputeDispatchProps ( ) {
124
- const nextDispatchProps = computeDispatchProps ( this . store , this . props ) ;
131
+ updateDispatchProps ( props = this . props ) {
132
+ const nextDispatchProps = computeDispatchProps ( this . store , props ) ;
125
133
if ( shallowEqual ( nextDispatchProps , this . dispatchProps ) ) {
126
134
return false ;
127
135
}
@@ -130,25 +138,7 @@ export default function createConnect(React) {
130
138
return true ;
131
139
}
132
140
133
- computeNextState ( props = this . props ) {
134
- const propsHaveChanged = ! shallowEqual ( this . props , props ) ;
135
-
136
- if ( shouldUpdateStateProps && propsHaveChanged ) {
137
- this . stateProps = computeStateProps ( this . store , props ) ;
138
- }
139
-
140
- if ( shouldUpdateDispatchProps && propsHaveChanged ) {
141
- this . dispatchProps = computeDispatchProps ( this . store , props ) ;
142
- }
143
-
144
- return computeNextState (
145
- this . stateProps ,
146
- this . dispatchProps ,
147
- props
148
- ) ;
149
- }
150
-
151
- recomputeState ( props = this . props ) {
141
+ updateState ( props = this . props ) {
152
142
const nextState = this . computeNextState ( props ) ;
153
143
if ( ! shallowEqual ( nextState , this . state . props ) ) {
154
144
this . setState ( {
@@ -181,7 +171,15 @@ export default function createConnect(React) {
181
171
182
172
componentWillReceiveProps ( nextProps ) {
183
173
if ( ! shallowEqual ( nextProps , this . props ) ) {
184
- this . recomputeState ( nextProps ) ;
174
+ if ( shouldUpdateStateProps ) {
175
+ this . updateStateProps ( nextProps ) ;
176
+ }
177
+
178
+ if ( shouldUpdateDispatchProps ) {
179
+ this . updateDispatchProps ( nextProps ) ;
180
+ }
181
+
182
+ this . updateState ( nextProps ) ;
185
183
}
186
184
}
187
185
@@ -190,8 +188,8 @@ export default function createConnect(React) {
190
188
}
191
189
192
190
handleChange ( ) {
193
- if ( this . recomputeStateProps ( ) ) {
194
- this . recomputeState ( ) ;
191
+ if ( this . updateStateProps ( ) ) {
192
+ this . updateState ( ) ;
195
193
}
196
194
}
197
195
@@ -227,9 +225,9 @@ export default function createConnect(React) {
227
225
228
226
// Update the state and bindings.
229
227
this . trySubscribe ( ) ;
230
- this . recomputeStateProps ( ) ;
231
- this . recomputeDispatchProps ( ) ;
232
- this . recomputeState ( ) ;
228
+ this . updateStateProps ( ) ;
229
+ this . updateDispatchProps ( ) ;
230
+ this . updateState ( ) ;
233
231
} ;
234
232
}
235
233
0 commit comments