Performance: When NgRx is overkill
MEDIUM IMPACT
Using NgRx unnecessarily affects initial load time and interaction responsiveness by adding extra bundle size and complex state management overhead.
import { Component } from '@angular/core'; @Component({ ... }) export class SimpleComponent { value = ''; updateValue(newValue: string) { this.value = newValue; } }
import { Store } from '@ngrx/store'; import { Component } from '@angular/core'; @Component({ ... }) export class SimpleComponent { constructor(private store: Store) {} updateValue(value: string) { this.store.dispatch({ type: 'UPDATE_VALUE', payload: value }); } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| NgRx for simple local state | Minimal DOM nodes but complex JS updates | Multiple reflows due to frequent state changes | Higher paint cost from slower JS execution | [X] Bad |
| Local component state or Angular signals | Minimal DOM nodes with direct updates | Single reflow per update | Lower paint cost with fast JS execution | [OK] Good |