Performance: State schema definition
MEDIUM IMPACT
Defines how state data is structured and validated, impacting memory usage and update efficiency during runtime.
const stateSchema = { user: { name: 'string', age: 'number' }, settings: { theme: ['light', 'dark'] } }; // Strict schema validation and pruningconst state = { user: { name: 'Alice', age: 30, extra: 'unused' }, settings: { theme: 'dark' } }; // No schema validation or pruning| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No schema validation | High due to redundant updates | Multiple reflows per update | High paint cost | [X] Bad |
| Strict state schema | Minimal DOM updates | Single reflow per update | Low paint cost | [OK] Good |