lang-react

Move complex logic from React components into external Zustand, XState, or TanStack Query stores.

Updated Nov 4, 2025
One-click install
npx skills add https://github.com/codethread/claude-code-plugins --skill lang-react
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lang-react
Source: https://github.com/codethread/claude-code-plugins/tree/main/plugins/langs/skills/lang-react
Command: npx skills add https://github.com/codethread/claude-code-plugins --skill lang-react

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill codifies the pattern of building React SPAs where components are declarative and rely on external stores or state machines (Zustand/XState/TanStack Query), keeping logic out of components.

Core Features & Use Cases

  • Stores and machines tested in isolation; components focus on rendering
  • Recommendations for state management stacks: TanStack Query, Zustand, XState
  • Guidance on patterns like inline props, pattern matching, and CSS-in-JS
  • Use Case: Build a dashboard by composing store-based logic and render with minimal component state

Quick Start

Create a small sample app that uses a Zustand store to fetch and display user data, and verify it uses stores rather than component state for logic.

Frequently Asked Questions about lang-react

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

FAQPage Schema
How do I move complex logic out of React components into external state?

External state management with Zustand, XState, or TanStack Query keeps logic decoupled from components. Store your business logic, data fetching, and state transitions in these tools, then have components consume that state via hooks. This makes components purely presentational and your logic testable in isolation.

What's the best way to handle remote data fetching in React without component state?

TanStack Query and Zustand handle remote data fetching and caching at the store level. Define queries or mutations in your store, manage loading and error states there, and pass only the resolved data to components. Components become simple renderers of store state.

How do I structure state machines in React with XState?

XState lets you define state machines outside components and invoke them as stores. Machine logic handles all state transitions deterministically; components subscribe to machine state and dispatch events. Test machines independently to verify behavior before connecting UI.

Can I use Zustand and XState together in the same React app?

Yes. Zustand works well for simpler, action-based state while XState excels at complex state machines. Use Zustand for UI state and remote data caching, XState for multi-step workflows or domain logic. Both integrate cleanly with React hooks.

Why should components avoid internal logic when using external stores?

Components with internal logic become harder to test, reuse, and reason about. External stores centralize logic, making it testable in isolation and reusable across components. Keeping components declarative and store-centric improves maintainability and catches bugs earlier.

Do I need to learn all three tools—Zustand, XState, and TanStack Query—to use this pattern?

No. Start with one based on your needs: TanStack Query for remote data, Zustand for application state, XState for state machines. Many apps use just one or two. The pattern is about externalizing logic; the tool choice depends on complexity and scale.