Skip to content

Commit 35c6d2a

Browse files
committed
fix(toaster): Unexpected state: no hydration info available for a given TNode, which represents a view container. [Expected=> null != undefined <=Actual] - ensure that the contentToasts is available before accessing it - tempfix
1 parent e6e04d2 commit 35c6d2a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<ng-template cToasterHost />
2-
<ng-content cToasterHost />
2+
<ng-content />

projects/coreui-angular/src/lib/toast/toaster/toaster.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
computed,
55
contentChildren,
66
DestroyRef,
7+
effect,
78
ElementRef,
89
inject,
910
Injector,
@@ -84,6 +85,12 @@ export class ToasterComponent implements OnInit {
8485
readonly toasterHost = viewChild.required(ToasterHostDirective);
8586
readonly contentToasts = contentChildren(ToastComponent, { read: ViewContainerRef });
8687

88+
readonly #contentToastsEffect = effect(() => {
89+
// Ensure that the contentToasts is available before accessing it
90+
// temp fix for: ASSERTION ERROR: Unexpected state: no hydration info available for a given TNode, which represents a view container. [Expected=> null != undefined <=Actual]
91+
this.contentToasts();
92+
});
93+
8794
readonly hostClasses = computed(() => {
8895
const placement = this.placement;
8996
const position = this.position();
@@ -143,7 +150,7 @@ export class ToasterComponent implements OnInit {
143150
this.contentToasts()?.forEach((item) => {
144151
if (state.toast && item.element.nativeElement === state.toast.hostElement.nativeElement) {
145152
if (!state.toast.dynamic()) {
146-
state.toast['visible'] = false;
153+
state.toast.visible = false;
147154
}
148155
}
149156
});

0 commit comments

Comments
 (0)