Bird
0
0

Will the child detect the change and update its view?

hard📝 Application Q15 of 15
Angular - Performance Optimization
You have a parent component passing an object as input to a child component using OnPush strategy. The parent updates a property inside the object without changing the object reference. Will the child detect the change and update its view?
ANo, because OnPush only detects changes when the input reference changes.
BYes, but only if you call <code>markForCheck()</code> manually.
CYes, because OnPush detects deep changes inside objects automatically.
DNo, because OnPush disables all change detection for objects.
Step-by-Step Solution
Solution:
  1. Step 1: Understand OnPush input change detection

    OnPush detects changes by checking if the input reference changes, not deep object mutations.
  2. Step 2: Analyze object mutation effect

    Changing a property inside the object without changing the reference does not trigger OnPush detection.
  3. Step 3: Evaluate other options

    Yes, because OnPush detects deep changes inside objects automatically. is false because OnPush does not do deep checks. Yes, but only if you call markForCheck() manually. is partially true but not automatic. No, because OnPush disables all change detection for objects. is incorrect; OnPush does not disable detection for objects.
  4. Final Answer:

    No, because OnPush only detects changes when the input reference changes. -> Option A
  5. Quick Check:

    OnPush detects input reference changes only = C [OK]
Quick Trick: OnPush tracks input references, not deep object changes [OK]
Common Mistakes:
  • Assuming deep object changes trigger OnPush
  • Thinking OnPush disables detection for objects
  • Forgetting to update object reference to trigger detection

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes