본문으로 건너뛰기
cccskills
무료GitHub에 공개

react

React Rules of React — strict adherence required for React Compiler compatibility. Covers purity, idempotency, immutability, hook call rules, and component rendering rules. Use when writing any React component, custom hook, or reviewing React code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(5)

  • SKILL.md4.7 KB
  • components-and-hooks-must-be-pure.md17.1 KB
  • index.md4.2 KB
  • react-calls-components-and-hooks.md4.8 KB
  • rules-of-hooks.md3.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Purpose

Enforce the Rules of React so that React Compiler can automatically memoize components and hooks at build time, eliminating the need for manual useMemo/useCallback/React.memo. Violations of these rules cause incorrect memoization and subtle bugs.

When this skill applies

  • Writing or reviewing any React function component or custom hook
  • Debugging unexpected re-renders, stale state, or memoization problems
  • Evaluating whether code is React Compiler-compatible
  • Any time you see use client, useState, useEffect, useMemo, useCallback, or custom use* hooks

The Three Pillars (read the detail files)

PillarFileKey concern
Components and Hooks must be purecomponents-and-hooks-must-be-pure.mdIdempotency, no side effects in render, immutability
React calls Components and Hooksreact-calls-components-and-hooks.mdNever call components directly, never pass hooks as values
Rules of Hooksrules-of-hooks.mdTop-level only, React functions only
Overview / indexindex.mdSummary of all rules with links to sections

Critical rules — enforce these without exception

Purity

  • Components and hooks must be idempotent. Same inputs (props, state, context, args) → same output, every time. new Date(), Math.random(), and any non-deterministic calls must live in useEffect or event handlers — never in render.
  • No side effects in render. DOM writes (document.title = …), network calls, subscriptions, and logging must not happen at the top level of a component function. Use useEffect or event handlers.
  • Local mutation is fine. Creating and mutating a local array or object within a single render call is allowed — it never escapes the render scope.

Immutability

  • Never mutate props. Derive a new value instead: const url = new Url(item.url, base) not item.url = ….
  • Never mutate state directly. Always use the setter from useState. Mutating the state variable does not trigger a re-render.
  • Never mutate hook arguments or return values. Spread ({ ...icon }) before modifying. Hook internals may memoize based on reference identity — mutating breaks that.
  • Never mutate values after passing them to JSX. Create separate objects for each consumer before the JSX expression that uses them.

React controls rendering

  • Never call component functions directly. <Article /> yes, Article() no. Direct calls bypass React's reconciler, break hook rules, and prevent optimizations.
  • Never pass hooks as values. No higher-order hooks (withLogging(useData)), no hook props (<Button useData={hook} />). Hooks are always called inline and statically.
  • Hooks must be static. The set of hooks a component calls must be the same on every render — no conditional hook creation.

Rules of Hooks (call-site rules)

  • Top level only. Never inside if, for, while, nested functions, event handlers, try/catch/finally, useMemo, useReducer, or useEffect callbacks.
  • React functions only. Only call hooks from function components or custom hooks (functions whose name starts with use). Never from plain JS functions, class components, or utilities.
  • After a conditional early return — move any hook call before the return.

React Compiler compatibility checklist

Before marking code as done, verify:

  • No new Date() / Math.random() in render body
  • No prop or state mutation
  • No DOM side effects at top level
  • All hooks called unconditionally at top level
  • Components only used as JSX, never called as functions
  • No hook passed as a prop or stored in a variable then called later
  • Hook arguments not mutated after being passed
  • Values not mutated after being passed to JSX

If any item fails, fix the violation rather than adding a // eslint-disable or "use no memo" directive. Reserve "use no memo" only for third-party code you cannot change.


ESLint enforcement

Install eslint-plugin-react-hooks and enable:

{
  "rules": {
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn"
  }
}

Use React's Strict Mode (<StrictMode>) in development — it double-invokes render to surface impure components.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

astro

무료

Reference for Astro — the core web framework the gatOS docs site (under site/) is built on. Use this when authoring or editing pages in site/, working with .astro/.md/.mdx files, content collections, the astro.config.mjs, or component/JSX-in-Markdown mechanics. Covers Astro component anatomy, using components in MDX, content collections, frontmatter, imports, expressions, and the build/dev commands — enough to work the site without leaving the repo. Pair with the `starlight` skill (the docs theme + its components) and the `tutorials` skill (the gatOS house style).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

meow-sci/gatOS132026년 10월 11일 업데이트

bun

무료

how to use bun effectively for scripting and sqlite and more

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

meow-sci/gatOS132026년 10월 11일 업데이트

gatos

무료

Write scripts and programs against gatOS — the KSA mod that exposes live Kitten Space Agency simulation state as a 9P filesystem at /sim (also over HTTP /v1, MQTT, and an AI-oriented MCP server). Use this when asked to read game/celestial/vehicle telemetry, control vehicles (throttle, ignite, staging, attitude, burns, RCS, lights, docking), use game/debug controls (teleport, impulse kick, refuel, time-warp, switch vessel), direct the in-game camera / author cinematic shots and tracks, schedule timed command sequences, or write flight-computer / autopilot programs. Covers the full /sim catalog, the command model, KSA coordinate frames, and worked Bun/TypeScript + Rust examples.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

meow-sci/gatOS132026년 10월 11일 업데이트

harmony

무료

Expert in use of Harmony Lib for runtime patching of dotnet C# code

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

meow-sci/gatOS132026년 10월 11일 업데이트

imgui

무료

ImGui is an immediate mode UI library. KSA uses ImGui for UI

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

meow-sci/gatOS132026년 10월 11일 업데이트

ksa

무료

detailed information about kitten space agency (KSA) game code, decompiled sources, modding patterns, architecture and best practices for working with mods and the game codebase

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

meow-sci/gatOS132026년 10월 11일 업데이트

meow-sci의 스킬 모두 보기

이 스킬의 문제 신고