
react-best-practices
Use when reading or writing React components (.tsx, .jsx files with React imports).
- Installs
- 3.2K
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/alleneubank/claude-code --skill react-best-practices- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads react-best-practices automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
React Best Practices
Pair with TypeScript
When working with React, always load both this skill and typescript-best-practices together. TypeScript patterns (type-first development, discriminated unions, Zod validation) apply to React code.
Core Principle: Effects Are Escape Hatches
Effects let you "step outside" React to synchronize with external systems. Most component logic should NOT use Effects. Before writing an Effect, ask: "Is there a way to do this without an Effect?"
Decision Tree
- Need to respond to user interaction? Use event handler
- Need computed value from props/state? Calculate during render
- Need cached expensive calculation? Use
useMemo - Need to reset state on prop change? Use
keyprop - Need to synchronize with external system? Use Effect with cleanup
- Need non-reactive code in Effect? Use
useEffectEvent - Need mutable value that doesn't trigger render? Use ref
When to Use Effects
Synchronizing with external systems: browser APIs (WebSocket, IntersectionObserver), third-party non-React libraries, window/document event listeners, non-React DOM elements (video, maps).
When NOT to Use Effects
- Derived state — calculate during render
- Expensive calculations — use
useMemo - Resetting state on prop change — use
keyprop - Responding to user events — use event handlers
- Notifying parent of state changes — update both in the same event handler
- Chains of effects — calculate derived state and update in one event handler
Refs
- Use for values that don't affect rendering (timer IDs, DOM node references)
- Never read or write
ref.currentduring render; only in event handlers and effects - Use ref callbacks (not
useRefin loops) for dynamic lists - Use
useImperativeHandleto limit what parent can access
Custom Hooks
- Share logic, not state — each call gets an independent state instance
- Name
useXxxonly if it actually calls other hooks; otherwise use a regular function - Avoid lifecycle hooks (
useMount,useEffectOnce) — useuseEffectdirectly so the linter catches missing deps - Keep focused on a single concrete use case
Component Patterns
- Controlled: parent owns state; uncontrolled: component owns state
- Prefer composition with
childrenover prop drilling - Treat boolean props that switch large component trees (
isEditing,isThread,hideAttachments) as a composition smell; prefer separate composed components for distinct use cases - For complex reusable UI, prefer compound components with provider-scoped state/actions over monolithic components with many optional props
- Use Context for scoped component families as well as truly global state, when it defines a local interface consumed by descendants
- Render JSX directly for UI variation; avoid config-array mini-frameworks unless the config is real domain data
- Lift the provider boundary when sibling or external controls need access to the same state/actions
- Use
flushSyncwhen you need to read the DOM synchronously after a state update
See react-patterns.md for code examples and detailed patterns.
FAQ
What does the react-best-practices skill do?
Use when reading or writing React components (.tsx, .jsx files with React imports).
How do I install react-best-practices?
Run npx skills add https://github.com/alleneubank/claude-code --skill react-best-practices in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/react-best-practices/ (personal) or .claude/skills/react-best-practices/ (project).
Which AI agents can use react-best-practices?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is react-best-practices safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains react-best-practices?
It is published by alleneubank in alleneubank/claude-code. It has 3,161 recorded installs.
More from alleneubank/claude-code
typescript-best-practices
alleneubank/claude-code
Use when reading or writing TypeScript or JavaScript files (.ts, .tsx, .js, tsconfig.json).
python-best-practices
alleneubank/claude-code
Use when reading or writing Python files (.py, pyproject.toml, requirements.txt).
web-fetch
alleneubank/claude-code
Fetches web content as clean markdown by preferring markdown-native responses and falling back to selector-based HTML extraction. Use for documentation, articles, and reference pages at http/https URLs.
nix-best-practices
alleneubank/claude-code
Use when working with Nix flakes, overlays, shell.nix, or flake.nix files.
zig-best-practices
alleneubank/claude-code
Use when reading or writing Zig files (.zig, build.zig, build.zig.zon).
playwright-best-practices
alleneubank/claude-code
Open the skill to read its SKILL.md instructions.
Popular frontend & design skills
setup-matt-pocock-skills
mattpocock/skills
Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.
frontend-design
anthropics/skills
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.
hyperframes-animation
heygen-com/hyperframes
All animation knowledge for HyperFrames — atomic motion rules, multi-phase scene blueprints, scene transitions, broader motion-design techniques, AND the seven runtime adapters (GSAP default, plus Lottie, Three.js, Anime.js, CSS keyframes, Web Animations API, TypeGPU). Use for any motion or animation task: pick 2-4 rules and compose, or load a blueprint, or look up runtime-specific API (e.g. GSAP eases / Lottie player / Three.js mixer). Also covers auditing an existing composition's choreography (animation map) and 24 named text-animation effects. HyperFrames-native: single paused timeline, seek-safe, deterministic.
prototype
mattpocock/skills
Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
hyperframes-core
heygen-com/hyperframes
The HyperFrames composition contract — build one renderable project. Use for composition structure, the data- timing attributes, class="clip", tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Read before writing composition HTML.
vercel-react-best-practices
vercel-labs/agent-skills
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.