@@ -455,69 +455,54 @@ export function commitClassLayoutLifecycles(
455
455
current : Fiber | null ,
456
456
) {
457
457
const instance = finishedWork . stateNode ;
458
- if ( current === null ) {
459
- // We could update instance props and state here,
460
- // but instead we rely on them being set during last render.
461
- // TODO: revisit this when we implement resuming.
462
- if ( __DEV__ ) {
463
- if (
464
- ! finishedWork . type . defaultProps &&
465
- ! ( 'ref' in finishedWork . memoizedProps ) &&
466
- ! didWarnAboutReassigningProps
467
- ) {
468
- if ( instance . props !== finishedWork . memoizedProps ) {
469
- console . error (
470
- 'Expected %s props to match memoized props before ' +
471
- 'componentDidMount. ' +
472
- 'This might either be because of a bug in React, or because ' +
473
- 'a component reassigns its own `this.props`. ' +
474
- 'Please file an issue.' ,
475
- getComponentNameFromFiber ( finishedWork ) || 'instance' ,
476
- ) ;
477
- }
478
- if ( instance . state !== finishedWork . memoizedState ) {
479
- console . error (
480
- 'Expected %s state to match memoized state before ' +
481
- 'componentDidMount. ' +
482
- 'This might either be because of a bug in React, or because ' +
483
- 'a component reassigns its own `this.state`. ' +
484
- 'Please file an issue.' ,
485
- getComponentNameFromFiber ( finishedWork ) || 'instance' ,
486
- ) ;
487
- }
458
+ // We could update instance props and state here,
459
+ // but instead we rely on them being set during last render.
460
+ // TODO: revisit this when we implement resuming.
461
+ if ( __DEV__ ) {
462
+ if (
463
+ ! finishedWork . type . defaultProps &&
464
+ ! ( 'ref' in finishedWork . memoizedProps ) &&
465
+ ! didWarnAboutReassigningProps
466
+ ) {
467
+ if ( instance . props !== finishedWork . memoizedProps ) {
468
+ console . error (
469
+ 'Expected %s props to match memoized props before ' +
470
+ 'componentDidUpdate. ' +
471
+ 'This might either be because of a bug in React, or because ' +
472
+ 'a component reassigns its own `this.props`. ' +
473
+ 'Please file an issue.' ,
474
+ getComponentNameFromFiber ( finishedWork ) || 'instance' ,
475
+ ) ;
488
476
}
489
- }
490
- if ( shouldProfile ( finishedWork ) ) {
491
- startEffectTimer ( ) ;
492
- if ( __DEV__ ) {
493
- runWithFiberInDEV (
494
- finishedWork ,
495
- callComponentDidMountInDEV ,
496
- finishedWork ,
497
- instance ,
477
+ if ( instance . state !== finishedWork . memoizedState ) {
478
+ console . error (
479
+ 'Expected %s state to match memoized state before ' +
480
+ 'componentDidUpdate. ' +
481
+ 'This might either be because of a bug in React, or because ' +
482
+ 'a component reassigns its own `this.state`. ' +
483
+ 'Please file an issue.' ,
484
+ getComponentNameFromFiber ( finishedWork ) || 'instance' ,
498
485
) ;
499
- } else {
500
- try {
501
- instance . componentDidMount ( ) ;
502
- } catch ( error ) {
503
- captureCommitPhaseError ( finishedWork , finishedWork . return , error ) ;
504
- }
505
486
}
506
- recordEffectDuration ( finishedWork ) ;
487
+ }
488
+ }
489
+ if ( shouldProfile ( finishedWork ) ) {
490
+ startEffectTimer ( ) ;
491
+ recordEffectDuration ( finishedWork ) ;
492
+ }
493
+ if ( current === null ) {
494
+ if ( __DEV__ ) {
495
+ runWithFiberInDEV (
496
+ finishedWork ,
497
+ callComponentDidMountInDEV ,
498
+ finishedWork ,
499
+ instance ,
500
+ ) ;
507
501
} else {
508
- if ( __DEV__ ) {
509
- runWithFiberInDEV (
510
- finishedWork ,
511
- callComponentDidMountInDEV ,
512
- finishedWork ,
513
- instance ,
514
- ) ;
515
- } else {
516
- try {
517
- instance . componentDidMount ( ) ;
518
- } catch ( error ) {
519
- captureCommitPhaseError ( finishedWork , finishedWork . return , error ) ;
520
- }
502
+ try {
503
+ instance . componentDidMount ( ) ;
504
+ } catch ( error ) {
505
+ captureCommitPhaseError ( finishedWork , finishedWork . return , error ) ;
521
506
}
522
507
}
523
508
} else {
@@ -527,82 +512,26 @@ export function commitClassLayoutLifecycles(
527
512
finishedWork . elementType === finishedWork . type ,
528
513
) ;
529
514
const prevState = current . memoizedState ;
530
- // We could update instance props and state here,
531
- // but instead we rely on them being set during last render.
532
- // TODO: revisit this when we implement resuming.
515
+
533
516
if ( __DEV__ ) {
534
- if (
535
- ! finishedWork . type . defaultProps &&
536
- ! ( 'ref' in finishedWork . memoizedProps ) &&
537
- ! didWarnAboutReassigningProps
538
- ) {
539
- if ( instance . props !== finishedWork . memoizedProps ) {
540
- console . error (
541
- 'Expected %s props to match memoized props before ' +
542
- 'componentDidUpdate. ' +
543
- 'This might either be because of a bug in React, or because ' +
544
- 'a component reassigns its own `this.props`. ' +
545
- 'Please file an issue.' ,
546
- getComponentNameFromFiber ( finishedWork ) || 'instance' ,
547
- ) ;
548
- }
549
- if ( instance . state !== finishedWork . memoizedState ) {
550
- console . error (
551
- 'Expected %s state to match memoized state before ' +
552
- 'componentDidUpdate. ' +
553
- 'This might either be because of a bug in React, or because ' +
554
- 'a component reassigns its own `this.state`. ' +
555
- 'Please file an issue.' ,
556
- getComponentNameFromFiber ( finishedWork ) || 'instance' ,
557
- ) ;
558
- }
559
- }
560
- }
561
- if ( shouldProfile ( finishedWork ) ) {
562
- startEffectTimer ( ) ;
563
- if ( __DEV__ ) {
564
- runWithFiberInDEV (
565
- finishedWork ,
566
- callComponentDidUpdateInDEV ,
567
- finishedWork ,
568
- instance ,
569
- prevProps ,
570
- prevState ,
571
- instance . __reactInternalSnapshotBeforeUpdate ,
572
- ) ;
573
- } else {
574
- try {
575
- instance . componentDidUpdate (
576
- prevProps ,
577
- prevState ,
578
- instance . __reactInternalSnapshotBeforeUpdate ,
579
- ) ;
580
- } catch ( error ) {
581
- captureCommitPhaseError ( finishedWork , finishedWork . return , error ) ;
582
- }
583
- }
584
- recordEffectDuration ( finishedWork ) ;
517
+ runWithFiberInDEV (
518
+ finishedWork ,
519
+ callComponentDidUpdateInDEV ,
520
+ finishedWork ,
521
+ instance ,
522
+ prevProps ,
523
+ prevState ,
524
+ instance . __reactInternalSnapshotBeforeUpdate ,
525
+ ) ;
585
526
} else {
586
- if ( __DEV__ ) {
587
- runWithFiberInDEV (
588
- finishedWork ,
589
- callComponentDidUpdateInDEV ,
590
- finishedWork ,
591
- instance ,
527
+ try {
528
+ instance . componentDidUpdate (
592
529
prevProps ,
593
530
prevState ,
594
531
instance . __reactInternalSnapshotBeforeUpdate ,
595
532
) ;
596
- } else {
597
- try {
598
- instance . componentDidUpdate (
599
- prevProps ,
600
- prevState ,
601
- instance . __reactInternalSnapshotBeforeUpdate ,
602
- ) ;
603
- } catch ( error ) {
604
- captureCommitPhaseError ( finishedWork , finishedWork . return , error ) ;
605
- }
533
+ } catch ( error ) {
534
+ captureCommitPhaseError ( finishedWork , finishedWork . return , error ) ;
606
535
}
607
536
}
608
537
}
0 commit comments