react-useeffect

React useEffect best practices guide covering when to use Effects and superior alternatives. Teaches the escape-hatch nature of Effects: use only for synchronizing with external systems, not for derived state, expensive calculations, or user event responses Provides a decision tree and quick-reference table mapping common situations (data fetching, state derivation, prop changes) to the correct React pattern Covers when NOT to use Effects: transforming data for render, handling user events, deriving state, and chaining state updates Recommends alternatives including direct calculation during render, useMemo for expensive computations, key prop for state reset, and useSyncExternalStore for subscriptions

INSTALLATION
npx skills add https://github.com/softaworks/agent-toolkit --skill react-useeffect
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$2c

  • 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

  • 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

BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card