6

I'm having a look to the example-app defined in the ngrx repo: https://github.com/ngrx/platform/tree/master/example-app

I can see that the ChangeDetectionStrategy.OnPush property is set only on "container" components while dummy components don't override the default change detection strategy.

Can anyone explain the reason? I would expect all the components in the application to use ChangeDetectionStrategy.OnPush

Thanks,

Gab

gabric
  • 1,865
  • 2
  • 21
  • 32

1 Answers1

11

There's no need to set ChangeDetectionStrategy.OnPush on every component as setting it on a parent component disables checking for the entire branch.

comp1 (ChangeDetectionStrategy.OnPush)
   comp2        <--- won't be checked
     comp3      <--- won't be checked

For more information on ChangeDetectionStrategy, read:

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
  • Does that also mean child components inherit this strategy? Or do they still have the default strategy? – S. Robijns Apr 11 '18 at 10:57
  • @S.Robijns, they have their default strategy, it's just that Change Detection doesn't reach them because of the parent componetn – Max Koretskyi Apr 11 '18 at 14:42