This is basically the React docs distilled into a decision tree for when you actually need useEffect versus when you're reaching for it out of habit. It covers the common antipatterns like using Effects for derived state or event handling, then shows you what to use instead: direct calculations, useMemo for expensive ops, key prop for resets, and plain event handlers. The quick reference table is especially useful during code review when you spot someone setting state in an Effect that should just be computed during render. Honestly, most useEffect bugs come from using it when you don't need an external system at all.

skills.sh installs
454
GitHub stars
33.2K
last updated
Aug 21, 2026

Install

$ npx -y skills add davila7/claude-code-templates --skill react-useeffect --agent claude-code

Installs into .claude/skills of the current project.

Files

You Might Not Need an Effect

Effects are an escape hatch from React. They let you synchronize with external systems. If there is no external system involved, you shouldn't need an Effect.

Quick Reference

SituationDON'TDO
Derived state from props/stateuseState + useEffectCalculate during render
Expensive calculationsuseEffect to cacheuseMemo
Reset state on prop changeuseEffect with setStatekey prop
User event responsesuseEffect watching stateEvent handler directly
Notify parent of changesuseEffect calling onChangeCall in event handler
Fetch datauseEffect without cleanupuseEffect with cleanup OR framework

When You DO Need Effects

  • Synchronizing with external systems (non-React widgets, browser APIs)
  • Subscriptions to external stores (use useSyncExternalStore when possible)
  • Analytics/logging that runs because component displayed
  • Data fetching with proper cleanup (or use framework's built-in mechanism)

When You DON'T Need Effects

Sponsors

Details

Repository
github.com/davila7/claude-code-templates
Categories
Frontend Development, Documentation
First seen
Jun 3, 2026

More from davila7/claude-code-templates

All 618
1aj-geddes avatargit-hooks-setupaj-geddes/useful-ai-promptsImplement Git hooks using Husky, pre-commit, and custom scripts. Enforce code quality, linting, and testing before commits and pushes.450skills.sh installs
2davila7 avatarfrontend-to-backend-requirementsdavila7/claude-code-templatesDocument frontend data needs for backend developers. Use when frontend needs to communicate API requirements to backend, or user says 'backend requirements', 'w441skills.sh installs
3incept5 avatareve-web-ui-testing-agent-browserincept5/eve-skillpacksWeb UI testing and browser automation. Use Vercel agent-browser for general apps, or the repo-pinned Playwright wrapper inside Eve Horizon. Use when tasks requi436skills.sh installs
4sickn33 avatarreact-native-architecturesickn33/antigravity-awesome-skillsreact native architecture425skills.sh installs
5ihlamury avatarlinear-ui-skillsihlamury/design-skillsLinear's UI design system. Use when building interfaces inspired by Linear's aesthetic - dark mode, Inter font, 4px grid.417skills.sh installs
6pproenca avatarexpo-react-native-coderpproenca/dot-skillsComprehensive Expo React Native feature development guide. This skill should be used when building mobile app screens, navigation, data fetching, authentication415skills.sh installs