Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngrx change detection strategy on dummy components

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

like image 399
gabric Avatar asked Sep 28 '17 12:09

gabric


1 Answers

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:

  • Everything you need to know about change detection in Angular

  • If you think ngDoCheck means your component is being checked — read this article

like image 166
Max Koretskyi Avatar answered Sep 29 '22 21:09

Max Koretskyi