no-use-effect

Enforce a restricted-syntax ban on React useEffect during component implementation and code review.

Updated Jun 8, 2024
One-click install
npx skills add https://github.com/shadeiskndr/portfolio --skill no-use-effect-shadeiskndr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: no-use-effect
Source: https://github.com/shadeiskndr/portfolio/tree/main/.agents/skills/no-use-effect
Command: npx skills add https://github.com/shadeiskndr/portfolio --skill no-use-effect-shadeiskndr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents unnecessary and error-prone React code patterns by eliminating direct useEffect calls and replacing them with safer, more declarative alternatives.

Core Features & Use Cases

  • Derived state without effects: Replace effects that mirror other state/props with inline computation to avoid extra renders and stale state.
  • Safer fetching and side effects: Use data-fetching libraries (e.g., query hooks) instead of effect-based fetching that can cause race conditions and duplicated caching logic.
  • Event-driven actions: Move user-triggered behavior into event handlers rather than “set a flag then run an effect” patterns.
  • One-time mount integration: Use useMountEffect as an explicit escape hatch for setup/cleanup on mount with stable dependencies.
  • Reset by remounting: Use the key prop on a parent to reset component state instead of dependency-choreographed effects.

Quick Start

When reviewing or writing React components, replace any direct useEffect usage with the appropriate pattern from the Skill and use useMountEffect only for true mount-time external synchronization.

Frequently Asked Questions about no-use-effect

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

FAQPage Schema
How do I remove useEffect from my React components?

You can remove useEffect by replacing it with inline derived computations for state mirroring, event handlers for user actions, and data-fetching libraries for async requests to write cleaner React code.

Why should I avoid using useEffect for data fetching?

Avoid useEffect for data fetching because it causes race conditions and duplicated caching logic. Dedicated data-fetching libraries and query hooks provide safer fetching and automatic state synchronization.

What is the best way to reset React component state without useEffect?

The best way to reset component state without useEffect is key-based remounting. Passing a changing key prop to the parent component forces a complete remount, eliminating dependency-choreographed reset effects.

When do I actually need a mount effect in React?

You need a mount effect strictly for one-time external synchronization setup and cleanup. Using a useMountEffect escape hatch with an explicit empty dependency pattern ensures safe mount-time integration.

Can ESLint enforce rules against overusing useEffect?

Yes, ESLint can enforce rules against overusing useEffect by applying a restricted-syntax ban. This prevents developers from introducing useEffect "just in case" during React component implementation and code review.

How do I calculate derived state in React without effects?

Calculate derived state in React without effects by using inline computation during render. Replacing effects that mirror state or props with direct calculations avoids extra renders and prevents stale state bugs.