Tooluck logoTooluck
SKILL.md

react-useeffect

Agent skill fromsoftaworks/agent-toolkit

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.

How to install react-useeffect

install react-useeffect
# install the agent-toolkit pack with the skills CLI
npx skills add softaworks/agent-toolkit

# or add only this skill to Claude Code: copy the folder

skills/react-useeffect/

# into

~/.claude/skills/react-useeffect/ (all projects)

.claude/skills/react-useeffect/ (one project)

skills/react-useeffect/SKILL.md

MITFull file
1# You Might Not Need an Effect
2
3Effects 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.
4
5## Quick Reference
6
7| Situation | DON'T | DO |
8|-----------|-------|-----|
9| Derived state from props/state | `useState` + `useEffect` | Calculate during render |
10| Expensive calculations | `useEffect` to cache | `useMemo` |
11| Reset state on prop change | `useEffect` with `setState` | `key` prop |
12| User event responses | `useEffect` watching state | Event handler directly |
13| Notify parent of changes | `useEffect` calling `onChange` | Call in event handler |
14| Fetch data | `useEffect` without cleanup | `useEffect` with cleanup OR framework |
15
16## When You DO Need Effects
17
18- Synchronizing with **external systems** (non-React widgets, browser APIs)
19- **Subscriptions** to external stores (use `useSyncExternalStore` when possible)
20- **Analytics/logging** that runs because component displayed
21- **Data fetching** with proper cleanup (or use framework's built-in mechanism)
22
23## When You DON'T Need Effects
24
251. **Transforming data for rendering** - Calculate at top level, re-runs automatically
262. **Handling user events** - Use event handlers, you know exactly what happened
273. **Deriving state** - Just compute it: `const fullName = firstName + ' ' + lastName`
284. **Chaining state updates** - Calculate all next state in the event handler
29
30## Decision Tree
31
32```
33Need to respond to something?
34…

Excerpt shown under the repository's MIT license.

More skills in agent-toolkit

Keep exploring

Similar skill repositories

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates