Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core):
afterRender
hooks now only run on ApplicationRef.tick
The `afterRender` hooks currently run after `ApplicationRef.tick` but also run after any call to `ChangeDetectorRef.detectChanges`. This is problematic because code which uses `afterRender` cannot expect the component it's registered from to be rendered when the callback executes. If there is a call to `ChangeDetectorRef.detectChanges` before the global change detection, that will cause the hooks to run earlier than expected. This behavior is somewhat of a blocker for the zoneless project. There is plenty of application code that do things like `setTimeout(() => doSomethingThatExpectsComponentToBeRendered())`, `NgZone.onStable(() => ...)` or `ApplicationRef.onStable...`. `ApplicationRef.onStable` is a should likely work similarly, but all of these are really wanting an API that is `afterRender` with the requirement that the hook runs after the global render, not an individual CDRef instance. This change updates the `afterRender` hooks to only run when `ApplicationRef.tick` happens. fixes #52429 fixes #53232
- Loading branch information
Showing
8 changed files
with
178 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.