0

What happens if you set ChangeDetectionStrategy.OnPush but keep mutating objects in place?

author
subina kallyani
medium
0
329

Answer

Angular with OnPush only checks components when:

  1. An @Input() reference changes
  2. An event inside the component fires
  3. markForCheck() is called manually

If you mutate an object (like user.name = 'New') without creating a new reference, Angular will not detect the change, and the view won’t update.

Click to Reveal Answer

Tap anywhere to see the solution

Revealed

Comments0
    What happens if you set ChangeDetectionStrategy.OnPush but keep mutating objects in place? - change detection | EBAT