alleneubank avatar

React Best Practices

Decision-tree guide for React components that steers logic away from unnecessary Effects toward render, events, and refs.

skills.sh installs
3K
GitHub stars
49
last updated
Jul 14, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers when to use Effects versus event handlers, render-time derivation, useMemo, key resets, and refs
  • Includes rules for refs, custom hooks, and composition patterns such as compound components and Context providers
  • Enforces that Effects are reserved for syncing with external systems like WebSockets, IntersectionObserver, and window listeners
  • Designed for .tsx and .jsx files with React imports, and meant to be loaded alongside typescript-best-practices

Install

$ npx -y skills add alleneubank/claude-code --skill react-best-practices -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

  1. Need to respond to user interaction? Use event handler
  2. Need computed value from props/state? Calculate during render
  3. Need cached expensive calculation? Use useMemo
  4. Need to reset state on prop change? Use key prop
  5. Need to synchronize with external system? Use Effect with cleanup
  6. Need non-reactive code in Effect? Use useEffectEvent
  7. 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).

Details

Repository
github.com/alleneubank/claude-code
Categories
Frontend & UI Code, Code Review & Quality
First seen
May 16, 2026

More from alleneubank/claude-code

All 8

Similar to React Best Practices

More Frontend & UI Code