react-useeffect-avoid

Guides React developers away from unnecessary useEffect usage toward render-time and event-driven alternatives.

Updated Apr 29, 2026
One-click install
npx skills add https://github.com/dev-khoi/AURA-conHack-2026 --skill react-useeffect-avoid-dev-khoi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: react-useeffect-avoid
Source: https://github.com/dev-khoi/AURA-conHack-2026/tree/main/.opencode/skills/react-useeffect-avoid
Command: npx skills add https://github.com/dev-khoi/AURA-conHack-2026 --skill react-useeffect-avoid-dev-khoi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? React developers frequently misuse useEffect for derived state, state resets, and user actions, causing double renders, stale data, tearing bugs, and cascading update chains that are hard to debug. ## Core Features & Use Cases - Anti-Pattern Detection: Identifies seven common useEffect mistakes including derived state, prop-change resets, effect waterfalls, and flag-based form submission. - Decision Tree Guidance: Provides a structured decision tree to determine whether useEffect, event handlers, key props, or useSyncExternalStore is the right tool. - Modern Alternatives: Covers React 19's use API, useSyncExternalStore for external subscriptions, and React Query patterns like mutate over mutateAsync. - Use Case: When reviewing a component that filters a list inside useEffect, this Skill explains the double-render problem and shows how to filter directly during render instead. ## Quick Start Review this React component and tell me whether its useEffect hooks are necessary or should be replaced with better patterns.

Frequently Asked Questions about react-useeffect-avoid

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I not use useEffect in React?▼

Avoid useEffect for derived state, state resets on prop changes, user-triggered actions, and list filtering. Calculate derived values during render, use the key prop for resets, and handle user actions in event handlers instead.

How do I reset component state when a prop changes?▼

Use the key prop to remount the component with fresh state when the prop changes, such as <UserForm key={userId} />. This avoids the stale-data flash and double render caused by resetting state inside useEffect.

What is the alternative to useEffect for data fetching?▼

Use data libraries like React Query or SWR, or React 19's use API to read promises directly during render. These handle caching, deduplication, and loading states without manual effect management.

Why does useEffect cause double renders in React?▼

Effects run after the initial render, so setting state inside useEffect triggers a second render cycle. Calculating values during render or handling logic in event handlers produces a single render with immediate UI updates.

Should I use useSyncExternalStore instead of useEffect for subscriptions?▼

Yes, useSyncExternalStore is the correct hook for subscribing to browser APIs and external stores. It prevents tearing bugs during concurrent rendering that occur with the useState plus useEffect subscription pattern.

When is useEffect actually the right choice?▼

Use useEffect only for synchronizing with external systems: websocket subscriptions, timers with cleanup, third-party library integration, document title changes, and analytics that fire after rendering completes.