@@ -219,6 +219,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
219219 this . mergedProps = null
220220 this . haveOwnPropsChanged = true
221221 this . hasStoreStateChanged = true
222+ this . haveStatePropsBeenPrecalculated = false
222223 this . renderedElement = null
223224 this . finalMapDispatchToProps = null
224225 this . finalMapStateToProps = null
@@ -229,13 +230,21 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
229230 return
230231 }
231232
232- const prevStoreState = this . state . storeState
233233 const storeState = this . store . getState ( )
234+ const prevStoreState = this . state . storeState
235+ if ( pure && prevStoreState === storeState ) {
236+ return
237+ }
234238
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
238244 }
245+
246+ this . hasStoreStateChanged = true
247+ this . setState ( { storeState } )
239248 }
240249
241250 getWrappedInstance ( ) {
@@ -251,11 +260,13 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
251260 const {
252261 haveOwnPropsChanged,
253262 hasStoreStateChanged,
263+ haveStatePropsBeenPrecalculated,
254264 renderedElement
255265 } = this
256266
257267 this . haveOwnPropsChanged = false
258268 this . hasStoreStateChanged = false
269+ this . haveStatePropsBeenPrecalculated = false
259270
260271 let shouldUpdateStateProps = true
261272 let shouldUpdateDispatchProps = true
@@ -269,7 +280,9 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
269280
270281 let haveStatePropsChanged = false
271282 let haveDispatchPropsChanged = false
272- if ( shouldUpdateStateProps ) {
283+ if ( haveStatePropsBeenPrecalculated ) {
284+ haveStatePropsChanged = true
285+ } else if ( shouldUpdateStateProps ) {
273286 haveStatePropsChanged = this . updateStatePropsIfNeeded ( )
274287 }
275288 if ( shouldUpdateDispatchProps ) {
0 commit comments