react

react is a cursor rule for Cursor from nedcodes-ok/cursorrules-collection. It costs 565 tokens per session, scanned A, original, MIT.

A set of conventions for building React interfaces with functions, hooks, and reusable components. React is a JavaScript library for creating user interfaces.

In plain words
What is it for?
Use it when creating or reviewing React components, forms, hooks, state management, data fetching, tests, and accessibility-related code.
Why use it?
It gives consistent guidance for organising components, managing state, handling server data, and avoiding common performance and maintenance problems.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions Cursor.

Good fit Use it when creating or reviewing React components, forms, hooks, state management, data fetching, tests, and accessibility-related code.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/react
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for react

README.md
[![agentmods](https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/react/github.svg)](https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/react)
Your own site
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/react"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/react/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for react

Your own site · 80×15
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/react"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/react.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 565 This file is loaded in full into every session.
When invoked 565 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00565 $0.00565
Opus 5.5 $0.00226 $0.00226
Sonnet 5.5 $0.00113 $0.00113
Haiku 4.5 $0.00056 $0.00056

Measured 1mo ago against content hash 022a2f18c45b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

react scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • react — 100% identical, 0 lines differ
rules-mdc/frameworks/react.mdc · 55 lines

How it starts

The opening of the file, as written. The whole thing — 55 lines — stays where its author put it; the contents beside it link to each section on GitHub.

React Cursor Rules

You are an expert React developer. Follow these rules:

Components

  • Functional components only. No class components
  • Keep under 150 lines. Extract hooks and sub-components early
  • Named exports, one component per file
  • Descriptive names: UserProfileCard not Card
  • Colocate styles, tests, and types with the component file
  • Props interface named {ComponentName}Props, defined above the component
  • Default props via destructuring defaults, not defaultProps
  • Avoid spreading props blindly ({...props}). Be explicit about what's passed

State Management

  • useState for local UI state, useReducer for complex logic with multiple related values
  • Lift state only as high as needed — avoid prop drilling beyond 2 levels
  • Context for global concerns (theme, auth, locale). Never for frequently updating values
  • Server state belongs in TanStack Query or SWR, not useState/useReducer/Context
  • Derive values from existing state instead of syncing with useEffect
  • URL is state too: use searchParams for filters, pagination, selected tabs
  • Form state: use controlled inputs for validation, uncontrolled (refs) for simple forms

Hooks

  • Follow Rules of Hooks. Use ESLint plugin
  • Extract reusable logic into custom hooks (use* prefix)
  • useMemo/useCallback only with demonstrated performance need — profile first
  • Complete dependency arrays. Never disable exhaustive-deps
  • useEffect is for synchronization with external systems, not for derived state
  • Cleanup functions in useEffect for subscriptions, timers, event listeners
  • Custom hooks should return objects (not arrays) when returning 3+ values

Patterns

  • Composition over configuration: children/render props over config objects
  • Handle loading, error, and empty states in every data component
  • ErrorBoundary at route/feature boundaries, not around individual components
  • React.lazy + Suspense for route-level code splitting
  • Container/presenter split: logic hooks in containers, pure rendering in presenters
  • Avoid conditional hooks. Move conditions inside the hook or split components
  • Render lists in their own component to isolate re-renders

Read the full file on GitHub · 55 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 55 lines · 565 tokens per session scan A 022a2f18c45b

Subscribe to this mod's changes

react is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (38 stars, last pushed 7mo ago), licensed MIT. It adds 565 tokens to every session, about $0.0023 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.