react-useeffect
What it does
This skill teaches your AI agent to use React's useEffect only when it is needed. It is for developers whose React code has effects that could be simpler.
When to use it
- βWhen you write or review a useEffect in a React component.
- βWhen state is being synced with useState and useEffect in a way that feels clumsy.
- βWhen you fetch data or reset state in React and want the cleanest approach.
Skill link
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/react-useeffect/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βReview my React component and remove any useEffect calls that are not needed.β
5 new skills a week. 1 minute to read.
How it works
The agent checks each effect against a list of cases where Effects are not needed, such as derived values or event responses. It replaces them with simpler patterns like calculating during render or using event handlers.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
| Situation | DON'T | DO |
|---|---|---|
| Derived state from props/state | useState + useEffect |
Calculate during render |
| Expensive calculations | useEffect to cache |
useMemo |
| Reset state on prop change | useEffect with setState |
key prop |
| User event responses | useEffect watching state |
Event handler directly |
| Notify parent of changes | useEffect calling onChange |
Call in event handler |
| Fetch data | useEffect without cleanup |
useEffect with cleanup OR framework |
When You DO Need Effects
- Synchronizing with external systems (non-React widgets, browser APIs)
- Subscriptions to external stores (use
useSyncExternalStorewhen 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
- Transforming data for rendering - Calculate at top level, re-runs automatically
- Handling user events - Use event handlers, you know exactly what happened
- Deriving state - Just compute it:
const fullName = firstName + ' ' + lastName - Chaining state updates - Calculate all next state in the event handler
Decision Tree
Need to respond to something?
βββ User interaction (click, submit, drag)?
β βββ Use EVENT HANDLER
βββ Component appeared on screen?
β βββ Use EFFECT (external sync, analytics)
βββ Props/state changed and need derived value?
β βββ CALCULATE DURING RENDER
β βββ Expensive? Use useMemo
βββ Need to reset state when prop changes?
βββ Use KEY PROP on component
Detailed Guidance
- Anti-Patterns - Common mistakes with fixes
- Better Alternatives - useMemo, key prop, lifting state, useSyncExternalStore
FAQ
When is an Effect really needed?
It is needed to sync with external systems, such as browser APIs or subscriptions outside React.
What replaces an Effect for resetting state?
A key prop can reset a component's state when a prop changes.
What about data fetching?
Use an Effect with cleanup, or the framework's built-in data mechanism.
Details
Original description by the author
React useEffect best practices from official docs. Use when writing/reviewing useEffect, useState for derived values, data fetching, or state synchronization. Teaches when NOT to use Effect and better alternatives.
Popularity
- GitHub stars
- 33k
- Ranking position
- #8793
- License
- MIT
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
owasp-security
33kTeaches your agent OWASP security guidance for web apps, APIs, mobile, containers and AI agents, so it can spot common weaknesses and suggest fixes.
agent-management
33kLets your agent create, list, hibernate, wake, rename and delete AI agents using the AI Maestro command line, managing each agent's lifecycle.
agent-messaging
33kLets your agent send, receive and reply to signed messages between AI agents, using the Agent Messaging Protocol, mostly on your own machine.
docs-search
33kLets your agent search auto-generated code documentation for function signatures, class definitions and comments, so it checks the real API before changing code.
Similar skills
angular-developer
280kHelps your agent create Angular code and give project structure advice. Useful for starting new projects, creating code parts, or improving performance and accessibility.
frontend-a11y
280kHelps your agent make web interfaces accessible to everyone. It ensures websites and apps work well with screen readers and keyboard navigation.
frontend-patterns
280kHas your agent apply modern patterns in frontend development. It optimizes performance, manages state, and follows best practices in React and Next.js.