Skip to content

Commit 12eb4d0

Browse files
erkamyamanalxhub
authored andcommitted
docs: fix the ExpressionChanged notes in the lifecycle hooks guide
Changing state in the content and view hooks does not always throw ExpressionChangedAfterItHasBeenCheckedError. Content hooks run before the component's own template is checked, so only state an ancestor's template has rendered is affected. Signals schedule another pass instead of throwing, and an OnPush view is skipped by the default check.
1 parent b4b80c7 commit 12eb4d0

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎adev/src/content/guide/components/lifecycle.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ _content_) have been initialized.
183183

184184
You can use this lifecycle hook to read the results of
185185
[content queries](guide/components/queries#content-queries). While you can access the initialized
186-
state of these queries, attempting to change any state in this method results in an
187-
[ExpressionChangedAfterItHasBeenCheckedError](errors/NG0100)
186+
state of these queries, avoid changing non-signal state that an ancestor's template has already
187+
rendered. Doing so can result in an
188+
[ExpressionChangedAfterItHasBeenCheckedError](errors/NG0100).
188189

189190
### ngAfterContentChecked
190191

@@ -195,8 +196,8 @@ This method runs very frequently and can significantly impact your page's perfor
195196
defining this hook whenever possible, only using it when you have no alternative.
196197

197198
While you can access the updated state
198-
of [content queries](guide/components/queries#content-queries) here, attempting to
199-
change any state in this method results in
199+
of [content queries](guide/components/queries#content-queries) here, avoid changing non-signal
200+
state that an ancestor's template has already rendered. Doing so can result in
200201
an [ExpressionChangedAfterItHasBeenCheckedError](errors/NG0100).
201202

202203
### ngAfterViewInit
@@ -206,8 +207,8 @@ _view_) have been initialized.
206207

207208
You can use this lifecycle hook to read the results of
208209
[view queries](guide/components/queries#view-queries). While you can access the initialized state of
209-
these queries, attempting to change any state in this method results in an
210-
[ExpressionChangedAfterItHasBeenCheckedError](errors/NG0100)
210+
these queries, avoid changing non-signal state that a template has already rendered. Doing so can
211+
result in an [ExpressionChangedAfterItHasBeenCheckedError](errors/NG0100).
211212

212213
### ngAfterViewChecked
213214

@@ -218,9 +219,8 @@ This method runs very frequently and can significantly impact your page's perfor
218219
defining this hook whenever possible, only using it when you have no alternative.
219220

220221
While you can access the updated state of [view queries](guide/components/queries#view-queries)
221-
here, attempting to
222-
change any state in this method results in
223-
an [ExpressionChangedAfterItHasBeenCheckedError](errors/NG0100).
222+
here, avoid changing non-signal state that a template has already rendered. Doing so can result
223+
in an [ExpressionChangedAfterItHasBeenCheckedError](errors/NG0100).
224224

225225
### afterEveryRender and afterNextRender
226226

0 commit comments

Comments
 (0)