Imported from lewislpz/codex-dotfile (
.codex/skills/react-patterns/SKILL.md). Install upstream withnpx skills add lewislpz/codex-dotfile --skill react-patterns. Copyright stays with the author.
React Patterns
Boundaries
Use only after React is confirmed. Use frontend guidance for broader UX and TypeScript guidance for advanced type or tooling problems.
Operating Loop
- Detect React version, rendering environment, compiler use, framework conventions, state libraries, and test setup.
- Identify ownership of state, effects, async data, and errors.
- Prefer composition and colocated state; extract only when reuse or complexity justifies it.
- Keep effects synchronized with external systems rather than using them for derived state.
- Profile before performance optimization and verify user-visible behavior.
Decision Rules
- Follow the Rules of Hooks and preserve stable ownership boundaries.
- Choose local, lifted, contextual, server, or global state from actual scope.
- Treat memoization as a targeted optimization, especially when a compiler is active.
- Provide error recovery and preserve user input where practical.
- Test behavior and accessibility rather than component internals.
Optional Reference
Load legacy-guide.md for a compact pattern catalog after confirming its assumptions match the repository.