-
Notifications
You must be signed in to change notification settings - Fork 25k
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
ng-template gets rendered twice during hydration (when anchor comment node is not projected) #50543
Comments
(@jessicajaniuk and @AndrewKushnir for visibility.) |
@michael-hein thanks for reporting the issue and providing a repro, this is very helpful. I've performed the investigation and found out that what happens is that new nodes are being created for the template instead of reusing existing ones (hence, the duplication), but since you have the I further looked into why existing nodes were not picked up by the hydration and found out that the "anchor" comment node for the projected To fix the problem, you can add the (adding P4 priority for now and leaving this ticket open to discuss further with the team whether we need to improve this behavior) |
thanks for the fast response and for looking into it. I really appreciate it :) Yes the With the
|
@AndrewKushnir I have tried the
And my component looks like:
Essentially I want to remove the component tag from being rendered since that component adds two <ng-content /> tag inside the ng-template , and outside. Do I have to do anything else to prevent the component being rendered twice? |
@CarlosTorrecillas the problem that you describe might be different from the one reported here. Could you please try to update your app to v16.1.1 (most recent at this moment) and test the behavior once again? If the problem still exists, please create a minimal repro (in a form of a GitHub repository with a new |
Hi @AndrewKushnir , I do have version 16.1.1 and tried different things but the error seems to be there. I will try to get a sample repo with the issue tomorrow and will submit the defect accordingly |
Good morning @AndrewKushnir , I have created #50813 with all the repro steps in it. Let me know if you need further info. Thanks! |
+1
|
@jwittekind Could you provide a working repro on a github repo ? This basic example without its context doesn't seem to reproduce the issue. |
I had the same problem, and it was related to change detection, i fixed it by adding "changeDetection: ChangeDetectionStrategy.OnPush,", to "@component({})" for all of my components |
I can not confirm that adding "changeDetection: ChangeDetectionStrategy.OnPush," solves the problem for me |
I struggle to understand why this is considered a "minor issue" when Please just fix the issue. |
Which @angular/* package(s) are the source of the bug?
platform-browser
Is this a regression?
No
Description
when hydration is enabled and a component uses
ngTemplateOutlet
to render a template passed from a parent e.g. viaContentChild
then its getting rendered twice for the duration of the hydration.So it looks the like this if 'abc' is the template content
received from server
abc
during hydration
abc abc
<-- this looks sometimes a bit uglyafter hydration
abc
So is it possible that the passed template gets just once rendered during the hydration process?
The relevant code parts for reprodruction:
Please provide a link to a minimal reproduction of the bug
https://github.com/michael-hein/hydration-ng-template
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: