Performance: Exporting and importing components
MEDIUM IMPACT
This concept affects the bundle size and initial load time by controlling how components are included and shared in the app.
export function SmallComponent() { return <div>Small Component</div>; } // Import only what is needed import { SmallComponent } from './SmallComponent';
export default function BigComponent() { return <div>Big Component</div>; } // Importing everything import BigComponent from './BigComponent';
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Default export importing whole module | No extra DOM nodes | No extra reflows | No direct paint cost | [X] Bad |
| Named export importing only needed components | No extra DOM nodes | No extra reflows | No direct paint cost | [OK] Good |