Step 1: NgFor Performance Issue

The Problem

When using *ngFor without trackBy, Angular recreates all DOM elements when the array changes, even if most items remain the same. Open your console to see components being recreated.

Problematic Code:


  <app-card-item
    *ngFor="let card of cards"
    [card]="card"
    appLifecycleLogger
  />
          
Card 1

Card 1

Component Instance ID: 8ngxc

Card 2

Card 2

Component Instance ID: cywt0p

Card 3

Card 3

Component Instance ID: ekvay