React

From dean0x/devflow · View interactive version

React is an AI agent skill from the GitHub repository dean0x/devflow. This skill should be used when the user works with React components (.tsx/.jsx), asks about "hooks", "state management", "memo optimization", or discusses component composition.

How to use this skill

Skill file

React Patterns

Sources in references/sources.md.

Iron Law

COMPOSITION OVER PROPS [2][4][12]

Use children and compound components, not prop drilling. If a component has >5 props,

it's doing too much. Split it. If you're passing data through 3+ levels, use context

or composition. Props are for configuration, not data plumbing.

"Before You memo(), try solving it with composition." — Dan Abramov [4]

Component Structure

Hooks

Hooks must be called at the top level — never inside conditions, loops, or nested functions.

Effects synchronize with external systems; they are not lifecycle methods.

Every effect that subscribes must return a cleanup function. Deps must be complete — never omit to suppress warnings.

See references/hooks.md for rules of hooks, custom hooks, useReducer, and effect anti-patterns.

Performance

The React Compiler handles many memoizations automatically. For manual optimization, follow this priority:

  1. Composition first — "before you memo(), try passing children down"
  2. Extract primitives for useEffect deps — avoid object/array literals
  3. useMemo for expensive computations; useCallback for stable handlers to memoized children
  4. React.memo only when parent has stable, memoized callbacks
  5. Virtualize long lists (react-window); lazy-load heavy components

State Architecture

| Pattern | When to Use |

|---------|-------------|

| useState | Simple, independent values |

| useReducer | Complex state with multiple transitions |

| Context | Shared state across distant components |

| Server Components | Server-only data; zero bundle impact |

Server Components render on the server and stream to the client — no useEffect

or API route required for data fetching.

Extended References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.