you-might-not-need-state

Detect and refactor unnecessary React useState patterns in codebases using React Query and Zustand.

1|1|Updated May 13, 2026
One-click install
npx skills add https://github.com/bibektimilsina00/fuse_monorepo --skill you-might-not-need-state-bibektimilsina00
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: you-might-not-need-state
Source: https://github.com/bibektimilsina00/fuse_monorepo/tree/main/.agents/skills/you-might-not-need-state
Command: npx skills add https://github.com/bibektimilsina00/fuse_monorepo --skill you-might-not-need-state-bibektimilsina00

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps eliminate React anti-patterns where components store derived values, mirror props or React Query/server data into local useState, or rely on chained useEffect updates that create stale UI and hard-to-debug re-render loops.

Core Features & Use Cases

  • Detects derived-state stored in useState and replaces it with inline computation during render.
  • Flags server-state copied into useState (including sync patterns from React Query) so React Query remains the single source of truth, with the forms-only exception for user edits.
  • Identifies props mirrored into state and chained useEffect state updates, recommending direct prop usage or safer reset approaches.
  • Improves selection state modeling by storing IDs instead of duplicating whole objects, deriving objects from IDs.
  • Avoids duplicating Zustand or React Query by removing parallel local state that already exists in a store or cache.

Use Case: In a PR that adds a filter or selection UI, it can analyze the targeted folder or diff and rewrite state management so server data comes directly from React Query, derived values are computed during render, and selection uses IDs to prevent unnecessary rerenders.

Quick Start

Use the skill to analyze the current changes for unnecessary state by setting the scope to "src/components/" and keeping fix enabled, then apply the proposed refactors.

Frequently Asked Questions about you-might-not-need-state

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

FAQPage Schema
Why does my React component have stale UI and re-render loops when syncing React Query data into useState?

Copying React Query server data into useState causes stale UI and re-render loops because it duplicates the server state. You should access server data directly from React Query to keep it the single source of truth and remove chained useEffect updates.

How do I refactor derived state in React to avoid using useState for computed values?

To refactor derived state in React, remove the useState hook and compute the values inline during render. This prevents duplication and ensures your component always reflects the latest props without requiring chained effect-driven state updates.

What is the best way to manage selection state in React without duplicating whole objects?

The best way to manage React selection state is to store only the selected item IDs instead of duplicating whole objects. You can then derive the necessary objects directly from the stored IDs to prevent unnecessary rerenders and sync bugs.

Can I use this state refactoring approach if my project does not use Zustand and React Query?

This refactoring approach is designed for codebases where React Query and Zustand are already used for server and client state separation. It enforces constraints that server data must not be copied into useState or Zustand, ensuring proper state separation.

How do I stop mirroring React props into local component state safely?

To stop mirroring React props into local component state, remove the useState duplication and use the props directly. For cases requiring resets, adopt safer reset approaches rather than relying on chained useEffect state updates to sync the values.