React Skill
Best Practices
- Functional Components: Always use functional components with Hooks. Class components are legacy.
- Hooks Rules: Only call hooks at the top level. Don't call them inside loops/conditions.
- Encapsulation: Keep components small. If it does 2 things, split it.
- State Management:
useStatefor local UI state.useContextfor low-frequency global state (User, Theme).Zustand/Reduxfor high-frequency complex state.
Common Pitfalls
- Prop Drilling: Passing props down 5 levels. Use Composition (
children) or Context. - Effect Dependencies: Ignoring lint warnings for
useEffectdeps array. This causes stale closures or infinite loops. - Key Prop: Using
indexas key for dynamic lists. Use unique IDs.
References
Converted and distributed by TomeVault — claim your Tome and manage your conversions.