@@ -219,6 +219,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
219
219
this . mergedProps = null
220
220
this . haveOwnPropsChanged = true
221
221
this . hasStoreStateChanged = true
222
+ this . haveStatePropsBeenPrecalculated = false
222
223
this . renderedElement = null
223
224
this . finalMapDispatchToProps = null
224
225
this . finalMapStateToProps = null
@@ -229,13 +230,21 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
229
230
return
230
231
}
231
232
232
- const prevStoreState = this . state . storeState
233
233
const storeState = this . store . getState ( )
234
+ const prevStoreState = this . state . storeState
235
+ if ( pure && prevStoreState === storeState ) {
236
+ return
237
+ }
234
238
235
- if ( ! pure || prevStoreState !== storeState ) {
236
- this . hasStoreStateChanged = true
237
- this . setState ( { storeState } )
239
+ if ( pure && ! this . doStatePropsDependOnOwnProps ) {
240
+ if ( ! this . updateStatePropsIfNeeded ( ) ) {
241
+ return
242
+ }
243
+ this . haveStatePropsBeenPrecalculated = true
238
244
}
245
+
246
+ this . hasStoreStateChanged = true
247
+ this . setState ( { storeState } )
239
248
}
240
249
241
250
getWrappedInstance ( ) {
@@ -251,11 +260,13 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
251
260
const {
252
261
haveOwnPropsChanged,
253
262
hasStoreStateChanged,
263
+ haveStatePropsBeenPrecalculated,
254
264
renderedElement
255
265
} = this
256
266
257
267
this . haveOwnPropsChanged = false
258
268
this . hasStoreStateChanged = false
269
+ this . haveStatePropsBeenPrecalculated = false
259
270
260
271
let shouldUpdateStateProps = true
261
272
let shouldUpdateDispatchProps = true
@@ -269,7 +280,9 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
269
280
270
281
let haveStatePropsChanged = false
271
282
let haveDispatchPropsChanged = false
272
- if ( shouldUpdateStateProps ) {
283
+ if ( haveStatePropsBeenPrecalculated ) {
284
+ haveStatePropsChanged = true
285
+ } else if ( shouldUpdateStateProps ) {
273
286
haveStatePropsChanged = this . updateStatePropsIfNeeded ( )
274
287
}
275
288
if ( shouldUpdateDispatchProps ) {
0 commit comments