@@ -24,6 +24,7 @@ function tryCatch(fn, ctx) {
24
24
try {
25
25
return fn . apply ( ctx )
26
26
} catch ( e ) {
27
+ console . error ( e )
27
28
errorObject . value = e
28
29
return errorObject
29
30
}
@@ -88,6 +89,7 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
88
89
console.log("shouldComponentUpdate nextState.mergedPropsUpdated",nextState.mergedPropsUpdated)
89
90
*/
90
91
console . log ( "################## shouldComponentUpdate" , nextState . mergedPropsUpdated )
92
+ console . log ( "################## shouldComponentUpdate" , nextState )
91
93
return ! pure || nextState . mergedPropsUpdated
92
94
}
93
95
@@ -250,6 +252,9 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
250
252
251
253
252
254
// Fast track: bailout early because we don't need access to fresh props here
255
+ console . log ( "isStateChange" , isStateChange )
256
+ console . log ( "pure" , pure )
257
+ console . log ( "!this.doStatePropsDependOnOwnProps" , ! this . doStatePropsDependOnOwnProps )
253
258
if ( isStateChange && pure && ! this . doStatePropsDependOnOwnProps ) {
254
259
setStatePropsIfNeeded ( this . props )
255
260
if ( ! statePropsUpdated ) {
@@ -259,8 +264,9 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
259
264
}
260
265
261
266
262
- // Normal track: we precompute everything for shouldComponentUpdate, and try to reuse already done computation
263
- this . setState ( ( previousState , currentProps ) => {
267
+
268
+ const setStateFunction = ( previousState , currentProps ) => {
269
+
264
270
console . log ( "-> normal track with props=" , currentProps )
265
271
266
272
setStatePropsIfNeeded ( currentProps ) ;
@@ -278,7 +284,6 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
278
284
console . log ( "mergedProps" , mergedProps )
279
285
console . log ( "mergedPropsUpdated" , mergedPropsUpdated )
280
286
281
-
282
287
return {
283
288
error : undefined ,
284
289
storeState,
@@ -287,7 +292,20 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
287
292
mergedProps,
288
293
mergedPropsUpdated
289
294
}
295
+ }
296
+
297
+
298
+
299
+ this . lastSetStateFunction = setStateFunction
300
+ this . setState ( ( previousState , currentProps ) => {
301
+ if ( this . lastSetStateFunction === setStateFunction ) {
302
+ return setStateFunction ( previousState , currentProps )
303
+ }
304
+ else {
305
+ return previousState
306
+ }
290
307
} ) ;
308
+
291
309
}
292
310
293
311
getWrappedInstance ( ) {
0 commit comments