react-state

Guide React component design and state management with Dan Abramov's mental models.

Updated Feb 17, 2026
One-click install
npx skills add https://github.com/Objective-Arts/lens-dist --skill react-state-objective-arts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-state
Source: https://github.com/Objective-Arts/lens-dist/tree/main/canon/react-state
Command: npx skills add https://github.com/Objective-Arts/lens-dist --skill react-state-objective-arts

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers deeply understand and apply Dan Abramov's core React mental models and best practices, leading to more robust, maintainable, and understandable React applications.

Core Features & Use Cases

  • React Fundamentals: Clarifies core concepts like "Just JavaScript," "UI as a function of state," and render isolation.
  • Component Design: Guides on composition over configuration and inversion of control.
  • State Management: Provides patterns for useState, useReducer, and Context API usage.
  • Hooks Philosophy: Explains the correct use of useEffect and custom hooks.
  • Anti-Patterns: Highlights common pitfalls like premature abstraction and unnecessary memoization.
  • Use Case: A developer is struggling with stale closures in a React component. This Skill provides explanations and examples of "Each Render Has Its Own Everything" and "UI as a Function of State" to resolve the issue.

Quick Start

Explain the "UI as a function of state" principle in React with a code example.

Frequently Asked Questions about react-state

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

FAQPage Schema
How does React state management work with the UI as a function of state principle?

React state management works by treating the UI as a function of state, where the component output is determined entirely by the current state and props during that specific render. This mental model ensures the interface remains predictable and synchronized with underlying data.

When should I use useReducer vs useState for React component state?

You should use useReducer instead of useState when React component state involves multiple sub-values that depend on each other, or when the next state depends on complex transitions. This approach provides a more predictable state management decision framework than multiple independent useState hooks.

Why do I get stale closures in React useEffect and how do I fix them?

You get stale closures in React useEffect because each render has its own everything, capturing variables from the render scope where the effect was created. Fix them by applying the Just JavaScript mental model, ensuring the effect correctly recognizes the UI as a function of state.

What is composition over configuration in React component design?

Composition over configuration in React component design is a pattern advocating for building complex interfaces by combining smaller, focused components rather than relying on extensive configuration props. This inversion of control prevents premature abstraction and maintains flexible component APIs.

What are common React hooks anti-patterns I should avoid in frontend development?

Common React hooks anti-patterns to avoid include premature abstraction, unnecessary memoization, and misusing useEffect for data synchronization rather than side effects. Applying Dan Abramov's mental models helps identify these pitfalls and establishes a clear decision framework for correct hooks philosophy.

Do I need to understand Just JavaScript thinking to build React components correctly?

You need to understand Just JavaScript thinking to build React components correctly because it clarifies that React is fundamentally standard JavaScript. Mastering these mental models clarifies render isolation and state management, leading to more robust and maintainable frontend development.