react-useeffect-avoid

Identify React useEffect anti-patterns and recommend safer alternatives.

1|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/Thomashighbaugh/opencode --skill react-useeffect-avoid-thomashighbaugh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-useeffect-avoid
Source: https://github.com/Thomashighbaugh/opencode/tree/main/skills/react-useeffect-avoid
Command: npx skills add https://github.com/Thomashighbaugh/opencode --skill react-useeffect-avoid-thomashighbaugh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers and reviewers avoid misusing useEffect for local React logic, which commonly causes double renders, stale UI, cascading updates, and concurrency-related tearing. It clarifies when effects are required (external subscriptions, timers, third-party integrations) versus when render-time logic, event handlers, or remounting are better.

Core Features & Use Cases

  • Decision tree that distinguishes external synchronization from pure React logic and guides whether to use useEffect or alternatives.
  • Illustrated anti-patterns with corrected patterns for derived state, state resets, list filtering, user-action side effects, and external subscriptions.
  • Practical use cases: code reviews to remove unnecessary effects, refactoring forms to eliminate transient state bugs, and converting unsafe subscriptions to useSyncExternalStore for concurrency safety.

Quick Start

Ask the skill to review a React component for useEffect anti-patterns and recommend render-time calculations, event-handler conversions, or key-prop remount strategies.

Frequently Asked Questions about react-useeffect-avoid

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

FAQPage Schema
When should I avoid useEffect in React components?

Avoid useEffect for pure React logic like derived state, state resets, and list filtering to prevent double renders, stale UI, and concurrency tearing. Use render-time calculations, event handlers, or key-based remounting instead.

How do I fix useEffect anti-patterns causing unnecessary renders?

Fix useEffect anti-patterns by converting them to render-time calculations or moving side effects into event handlers. This eliminates cascading updates and transient state bugs during component rendering.

What is the best way to handle external subscriptions in React without useEffect?

Use useSyncExternalStore for external subscriptions to ensure concurrency safety. This prevents tearing and provides a more reliable alternative to managing third-party integrations with useEffect.

How do I reset React component state without misusing useEffect?

Reset component state using key-based remounting instead of useEffect. Changing the key prop remounts the component, automatically clearing transient state and avoiding stale UI bugs.

Does this approach to useEffect apply to form refactoring and code review?

Yes, this approach applies to form refactoring and code review. It helps eliminate transient state bugs in forms and identifies unnecessary effects during code reviews to improve React performance.

Why does useEffect cause stale UI and concurrency tearing in React?

useEffect causes stale UI and concurrency tearing when misused for local logic because it triggers cascading updates and double renders. Moving logic to render-time or event handlers prevents these issues.