Loading…
Loading…
The SettingsPage tree already exists in the project — user/theme/onLogout props are drilled through 4 levels. A colleague sent a PR adding dark mode: `isDarkMode` + `onToggleDarkMode` following the same pattern — drilled through every level. Walk the diff and suggest the right solution.
Prop drilling is fine **at 1–2 levels**. The problem starts when: 1. A prop passes through 3+ components that don't use it themselves. 2. Many components need the same value (theme, user, locale). 3. Adding a new cross-cutting parameter requires updating 5+ components. Solutions: - **Context** for UI state (theme, language, sidebar open). - **react-query / SWR** for server state (user, API data). - **Zustand / Redux** for complex global app state. - **Composition** (children props) when you can avoid global state altogether. Walk the code and find every drilled prop.