Bird
0
0

What happens if a component with OnPush change detection updates an internal variable but its input reference stays the same?

medium📝 component behavior Q5 of 15
Angular - Change Detection
What happens if a component with OnPush change detection updates an internal variable but its input reference stays the same?
AAngular will throw an error about change detection.
BAngular will NOT run change detection for that component automatically.
CAngular will always run change detection regardless of input changes.
DAngular will update the view immediately.
Step-by-Step Solution
Solution:
  1. Step 1: Recall OnPush detection rules

    OnPush only runs change detection when input references change or events inside the component occur.
  2. Step 2: Understand internal variable effect

    Changing internal variables without input change does not trigger detection automatically.
  3. Final Answer:

    Angular will NOT run change detection for that component automatically. -> Option B
  4. Quick Check:

    OnPush ignores internal variable changes [OK]
Quick Trick: Internal changes don't trigger OnPush detection [OK]
Common Mistakes:
MISTAKES
  • Assuming internal changes always update view
  • Expecting errors on internal changes
  • Believing OnPush ignores input changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes