discountry/ritmex-skills/react-principles

Claude Code and agent skill by discountry/ritmex-skills

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

React best practices for component design, state management, and Effect discipline. Use when writing, reviewing, or refactoring React components, custom hooks, or any .ts/.tsx/.js/.jsx file that uses React.

Install

npx vskill@latest install discountry/ritmex-skills/react-principles

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

React Development Principles

Component Model

  • Components are pure functions: (props, state) → JSX. Render must be side-effect-free.
  • One-way data flow: parent → child via props, child → parent via callbacks.
  • Never mutate state or props in-place.

Thinking in React: Design Process

  1. Hierarchy — decompose by SRP; one component, one concern. Map data model shape to component tree.
  2. Static first — props only, no state, until the skeleton renders correctly.
  3. Minimal state — DRY: if it's derivable, it's not state.
  4. Ownership — hoist state to the closest common ancestor of all consumers.
  5. Inverse flow — pass setters/handlers down; children call them on interaction.
What is NOT state
  • Computable from existing state or props → derive during render
  • Passed in as a prop
  • Unchanged over time

Prefer storing IDs/primitives; derive full objects at render time.

Effect Discipline

useEffect is for synchronizing with external systems only — DOM APIs, network connections, third-party widgets, browser subscriptions. It is not a lifecycle hook and not a data-transformation pipeline.

Deciding when to write an Effect
Why does this code run?
- Because the user did something → event handler
- Because the component must stay in sync with something external → Effect
Unnecessary Effects — replace with:
AntipatternCorrect approach
Derived state via useEffect + useStateCompute during render; useMemo if expensive
State reset on prop change via Effectkey prop
Partial state adjustment on prop changeStore primitive ID; derive object during render
Shared event logic routed through state+EffectExtract a plain function; call from event handlers
User-initiated POST in EffectMove directly into the event handler
Effect chains (A → Effect → B → Effect → C)Compute all next state in one event handler
Parent notification via EffectCall both setters in the same event handler; or lift state
Pushing data up to parent via EffectParent fetches; passes data down as prop
One-time app init in component EffectModule-level or didInit guard outside component
External store subscription via EffectuseSyncExternalStore
Data fetch without cleanupignore flag cleanup; prefer framework data-fetching
Effect rules
  • Every reactive value the Effect reads must be in its dependency array.
  • Never suppress react-hooks/exhaustive-deps — fix the code.
  • Every resource acquired in setup must be released in cleanup.
  • One Effect = one synchronization concern. Split unrelated concerns.
  • Think start sync / stop sync, not mount / unmount.

Key Heuristics

  1. If it's computable at render time — compute it. No state, no Effect.
  2. If it runs because the user did X — it's an event handler.
  3. If it runs because the component is visible — it's an Effect.
  4. If two state variables drift out of sync — lift state or derive one from the other.
  5. If the dep array is long — the Effect does too much; split it.
  6. If you want to suppress the deps linter — redesign instead.

Supporting Reference Files

Load these files when deeper guidance is needed for the specific topic at hand:

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/discountry/ritmex-skills/react-principles/badge)](https://verified-skill.com/skills/discountry/ritmex-skills/react-principles)

Something wrong with this skill or its page? Tell us.