title: Angular 9 - No component factory found for <component>
body: <p>After updating an Angular app from version 8 to 9, I'm getting the following error:
  <code>No component factory found for &lt;component&gt;. Did you add it to @NgModule.entryComponents?</code></p>
  
  <p>But as stated on <a href="https://update.angular.io/#8.2:9.0l3" rel="nofollow noreferrer">Angular Update Guide</a>, adding components to <code>entryComponents</code> should not be required anymore:</p>
  
  <blockquote>
    <p>With Angular 9 Ivy is now the default rendering engine</p>
  </blockquote>
  
  <p>...</p>
  
  <blockquote>
    <p>If you have specified any entryComponents in your NgModules or had any uses of ANALYZE_FOR_ENTRY_COMPONENTS, you can remove them. They are no longer required with the Ivy compiler and runtime.</p>
  </blockquote>
  
  <p>I'm using the following package versions:</p>
  
  <pre><code>"dependencies": {
    "@angular/animations": "~9.0.3",
    "@angular/cdk": "~9.1.0",
    "@angular/common": "~9.0.3",
    "@angular/compiler": "~9.0.3",
    "@angular/core": "~9.0.3",
    "@angular/forms": "~9.0.3",
    "@angular/material": "^9.1.0",
    "@angular/platform-browser": "~9.0.3",
    "@angular/platform-browser-dynamic": "~9.0.3",
    "@angular/router": "~9.0.3",
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.900.3",
    "@angular-devkit/build-ng-packagr": "~0.900.3",
    "@angular/cli": "~9.0.3",
    "@angular/compiler-cli": "~9.0.3",
    "@angular/language-service": "~9.0.3",
  }
  </code></pre>
  
  <p>This is the code I'm using to dynamically create components:</p>
  
  <pre><code>@ViewChild('target', {static: true, read: ViewContainerRef}) target: ViewContainerRef;
  @Input() componentType: Type&lt;Component&gt;;
  
  cmpRef: ComponentRef&lt;Component&gt;;
  
  constructor(private componentFactoryResolver: ComponentFactoryResolver) {}
  
  ngOnInit() {
    this.updateComponent();
  }
  
  ngOnChanges() {
    this.updateComponent();
  }
  
  ngOnDestroy() {
    if (this.cmpRef) {
      this.cmpRef.destroy();
    }
  }
  
  updateComponent() {
    if (this.cmpRef) {
      this.cmpRef.destroy();
    }
  
    const factory = this.componentFactoryResolver.resolveComponentFactory(this.componentType);
    this.cmpRef = this.target.createComponent(factory);
  }
  </code></pre>