Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is change detection called twice?

I have a simple test-component with no logic. I render this component. Why is the DoCheck hook called twice?

So far I understand, DoCheck is called for every change detection. But there is no change. I just render the component and DoCheck is already called two times. Also ngAfterContentChecked and ngAfterViewChecked.

enter image description here

like image 939
Catweazle Avatar asked Nov 02 '25 03:11

Catweazle


1 Answers

Angular Change Detection - How Does It Really Work?

... Angular always running change detection twice, the second time for detecting this type of cases. In production mode change detection is only run once

like image 125
Nail Achmedzhanov Avatar answered Nov 04 '25 14:11

Nail Achmedzhanov