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 componentDetailed Guidance
- Anti-Patterns - Common mistakes with fixes
- Better Alternatives - useMemo, key prop, lifting state, useSyncExternalStore
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 componentDetailed Guidance
- Anti-Patterns - Common mistakes with fixes
- Better Alternatives - useMemo, key prop, lifting state, useSyncExternalStore
Scanned by
NVIDIA SkillSpector
Automated static analysis (no LLM) · v2.12.0 · 2026-11-19
Partial analysis: some checks could not run on this component.
9 observations in 2 categories
- Memory Poisoning 8
- Analysis evasion 1
SkillSpector looks for patterns such as shell commands, credential access, network calls or unpinned dependencies. An observation is something worth reading in the files before you install, not a confirmed vulnerability. Components that run code locally, like hooks, MCP servers and security tooling, naturally show more of them. Open one to see the lines it points at.
Incomplete referenced artifact analysisAnalysis evasion · SKILL.md:52
| 50 | ## Detailed Guidance |
| 51 | |
| 52 | - [Anti-Patterns](./anti-patterns.md) - Common mistakes with fixes |
| 53 | - [Better Alternatives](./alternatives.md) - useMemo, key prop, lifting state, useSyncExternalStore |
Memory Manipulation ×4Memory Poisoning · README.md:30
| 28 | - "My Effect is causing too many re-renders" |
| 29 | - "Data fetching with useEffect" |
| 30 | - "Reset state when props change" |
| 31 | - "Derived state from props" |
| 32 |
Memory Manipulation ×2Memory Poisoning · SKILL.md:16
| 14 | | Derived state from props/state | `useState` + `useEffect` | Calculate during render | |
| 15 | | Expensive calculations | `useEffect` to cache | `useMemo` | |
| 16 | | Reset state on prop change | `useEffect` with `setState` | `key` prop | |
| 17 | | User event responses | `useEffect` watching state | Event handler directly | |
| 18 | | Notify parent of changes | `useEffect` calling `onChange` | Call in event handler | |
Memory ManipulationMemory Poisoning · anti-patterns.md:55
| 53 | |
| 54 | ```tsx |
| 55 | // BAD: Effect to reset state |
| 56 | function ProfilePage({ userId }) { |
| 57 | const [comment, setComment] = useState(''); |
Memory ManipulationMemory Poisoning · alternatives.md:49
| 47 | --- |
| 48 | |
| 49 | ## 3. Key Prop to Reset State |
| 50 | |
| 51 | To reset ALL state when a prop changes, use key: |
Learn more about NVIDIA SkillSpector or how components are reviewed.
Agent compatibility
Checked by NVIDIA SkillEvaluator Harness Check · v1.0.1 · 2026-11-18
How each agent reads this skill once it is installed, from the agents' documented loading rules. No agent was run. A note means the agent loads the skill but changes part of its text, or drops it.
Claude Code
loadsCodex
loadsCopilot CLI
loadsOpenCode
loadsHermes
loadsOpenClaw
loads
Every agent loads this skill as written. No notes.
Learn more about NVIDIA SkillEvaluator.