103176: Fix vcr not being defined yet in OnInit hook

This commit is contained in:
Alexandre Vryghem
2023-06-27 15:26:49 +02:00
parent e4f483c308
commit 928d7a45a3

View File

@@ -1,10 +1,10 @@
import { import {
AfterViewInit,
Component, Component,
ViewChild, ViewChild,
ViewContainerRef, ViewContainerRef,
ComponentRef, ComponentRef,
SimpleChanges, SimpleChanges,
OnInit,
OnDestroy, OnDestroy,
ComponentFactoryResolver, ComponentFactoryResolver,
ChangeDetectorRef, ChangeDetectorRef,
@@ -21,7 +21,7 @@ import { GenericConstructor } from '../../core/shared/generic-constructor';
styleUrls: ['./themed.component.scss'], styleUrls: ['./themed.component.scss'],
templateUrl: './themed.component.html', templateUrl: './themed.component.html',
}) })
export abstract class ThemedComponent<T> implements OnInit, OnDestroy, OnChanges { export abstract class ThemedComponent<T> implements AfterViewInit, OnDestroy, OnChanges {
@ViewChild('vcr', { read: ViewContainerRef }) vcr: ViewContainerRef; @ViewChild('vcr', { read: ViewContainerRef }) vcr: ViewContainerRef;
protected compRef: ComponentRef<T>; protected compRef: ComponentRef<T>;
@@ -49,7 +49,7 @@ export abstract class ThemedComponent<T> implements OnInit, OnDestroy, OnChanges
} }
} }
ngOnInit(): void { ngAfterViewInit(): void {
this.destroyComponentInstance(); this.destroyComponentInstance();
this.themeSub = this.themeService.getThemeName$().subscribe(() => { this.themeSub = this.themeService.getThemeName$().subscribe(() => {
this.renderComponentInstance(); this.renderComponentInstance();