As features grow, file structure matters as much as syntax. Teams organize by route, by feature, or by type (components/, hooks/). React does not mandate one layout—consistency within a repo beats any universal template.
Common patterns
- Feature folders —
checkout/Cart.tsx,checkout/useCart.tscolocated - Atomic tiers — atoms/molecules/organisms (design-system teams)
- Route-based — Next.js App Router maps folders to URLs automatically
Component size heuristics
Split when a file mixes unrelated state, repeats markup twice, or hides business rules inside JSX. Keep leaf components dumb (props in, UI out); push data fetching and reducers upward or into custom hooks.
Barrel exports
index.ts re-exporting a folder simplifies imports but can harm tree-shaking if it re-exports everything—export only what other features need.
Self-check
- When would you extract a child component vs a custom hook?
- What is one sign a component file should be split?