React Cheat Sheet
Comprehensive React reference covering JSX, hooks, component patterns, Context API, React Router, and TypeScript integration with practical code examples.
π Quick Navigation
React Best Practices
πͺ Prefer Function Components
Use function components with hooks β they are simpler, more composable, and the future of React
π Stable Keys in Lists
Always use unique, stable IDs as keys β avoid array indices unless the list is static and never reordered
π§Ή Clean Up Effects
Return a cleanup function from useEffect for subscriptions, timers, and async operations to prevent memory leaks
π¦ Collocate State
Keep state as close as possible to where it is used β lift state only when genuinely needed by siblings
π§© Small, Focused Components
Extract components when a chunk of JSX becomes complex or reusable β aim for single responsibility
β‘ Optimize Last
Profile with React DevTools before adding memo/useMemo/useCallback β premature optimization adds complexity without measurable gains