-
Notifications
You must be signed in to change notification settings - Fork 26.3k
docs: add page NG8115 (uninvokedTrackFunction) #61962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
docs: add page NG8115 (uninvokedTrackFunction) #61962
Conversation
Pull request that added the diagnostic: angular#60495
Thank you Enea! |
Co-authored-by: Matthieu Riegler <kyro38@gmail.com>
@@ -0,0 +1,61 @@ | |||
# Uninvoked Track Function | |||
|
|||
This diagnostic detects when a track function is not called in `@for` blocks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diagnostic detects when a track function is not called in `@for` blocks. | |
This diagnostic detects when a track function is not invoked in `@for` blocks. |
## What's wrong with that? | ||
|
||
`@for` blocks need to uniquely identify items in the iterable to correctly perform DOM updates when items in the iterable are reordered, new items are added, or existing items are removed. | ||
Passing just the function name to the track function without invoking the function will make the `@for` loop recreate the list everytime. The function need to be called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessarly true, but instead of the tracking value, the diffing algorithm will get the tracking function reference instead, which usally results in the framework logging the NG0955
warning (https://angular.dev/errors/NG0955)
Ensure to invoke the track function when you use it in a `@for` to execute the function so the loop can uniquely identify items. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure to invoke the track function when you use it in a `@for` to execute the function so the loop can uniquely identify items. | |
Ensure to invoke the track function when you use it in a `@for` block to execute the function so the loop can uniquely identify items. | |
Deployed adev-preview for 559c75f to: https://ng-dev-previews-fw--pr-angular-angular-61962-adev-prev-j0evihb3.web.app Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt. |
Adds documentation for
NG8115 (uninvokedTrackFunction)
Pull request that added the diagnostic:
#60495
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
This adds documentation for the extended diagnostic
NG8115 (uninvokedTrackFunction)
What is the current behavior?
No diagnostic for
NG8115 (uninvokedTrackFunction)
Issue Number: N/A
What is the new behavior?
Adds a diagnostic for
NG8115 (uninvokedTrackFunction)
Does this PR introduce a breaking change?
Other information
@eneajaho offered to check this out :0 ty
Fun fact: I noticed this while I was just going to make a change for the incorrect indentation that I did in the second commit lol.