react
Skill3 starsChanged 3 months agoMITView on GitHub
MUST USE when writing or editing React components, hooks, state management, effects, performance, loading/empty states, Zustand stores, or styling. Covers React 19.2 (use, Actions, useActionState, useOptimistic, useFormStatus, ref as prop, Context provider, Activity), the Rules of Hooks, React Compiler v1.0 memoization, component splitting and custom hooks, composition over boolean props, useEffect avoidance, re-render performance, list keys, loading skeletons and empty states, Zustand client-state stores, and Tailwind v4 design tokens.
30 other projects use a version of this.
Adopted by
Most recently taken up by
- lobehub/lobehubtheir own version, first seen Oct 1, 2026
- compozy/compozytheir own version, first seen Oct 1, 2026
- vercel-labs/json-rendertheir own version, first seen Sep 23, 2026
- dafaalz/agent-skillstheir own version, first seen Sep 22, 2026
- AvilaCarlosDev/openclaw-skillstheir own version, first seen Sep 19, 2026
- danielteles/awesome-agent-skillstheir own version, first seen Sep 2, 2026
Used with
Projects with it also use app-renderer-systems, refactoring-analysis and 8 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
pedronauckSkillapp-renderer-systems
Create, extend, or debug frontend domain modules organized under systems/. Covers adapters, Query hooks, local state, and public exports; excludes generic components and backend implementation.
Also in 3 projects that use this
pedronauckSkillrefactoring-analysis
Audit code quality and architectural health or plan refactoring using Fowler code smells and techniques; write prioritized findings to docs/_refacs/. Excludes formatting, performance, and security audits.
Also in 3 projects that use this
rogue-dev-studioSkillnodejs
Node.js development environment. Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `nodejs` work when listed in TEAM.yaml or explicitly requested.
Also in 6 projects that use this
akornmeierSkilltailwindcss
Guide for implementing Tailwind CSS - a utility-first CSS framework for rapid UI development. Use when styling applications with responsive design, dark mode, custom themes, or building design systems with Tailwind's utility classes.
Also in 6 projects that use this
MindrallySkillprisma
Expert in Prisma ORM with type-safe database operations and schema design
Also in 4 projects that use this
barisariburnuSkilltanstack
Expert assistance for TanStack Router, Query (v5), and Table (v8). Use when users need help with file-based routing, type-safe navigation, data loading, search params, queries, mutations, optimistic updates, infinite queries, table state management, or debugging TanStack libraries.
Also in 3 projects that use this
- +1 more from pedronauck
Other versions30 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 30
- lobehub/lobehub★ 83ksame name
- vercel-labs/json-render★ 18ksame name
- compozy/compozy★ 2.8ksame name
- openops-cloud/openops★ 1.1ksame name
- pedronauck/skills★ 633same name
- Mindrally/skills★ 266same name
- magnus919/agent-skills★ 109same name
- dylantarre/design-system-skills★ 50same name
- nimadorostkar/Claude-Skills-collection★ 28same name
- sordi-ai/skill-everything★ 20same name
20 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- code-structureSkill
- debuggingSkill
- docker-best-practicesSkill
- drf-best-practicesSkill
- drizzle-ormSkill
- expressSkill
- fastapiSkill
- git-merge-conflictsSkill
- researchSkill
- security-practicesSkill
- sqlSkill
- tanstack-querySkill
- tanstack-routerSkill
- testing-best-practicesSkill
- typescript-best-practicesSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 3 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 23 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 83
If a value can be computed from props or other state, it is not state.
- Very specific: line 119
Never both on one form — handleSubmit and <form action> both own submission.
- Very specific: line 191
If the copy must reset when the prop changes, use a key (gotcha 9).
- Distinctive: line 314
Always: use function components — no class components.
- Very specific: line 315
Always: treat ref as a normal prop.
- Very specific: line 317
Always: use use() to read context — never useContext.
- Very specific: line 319
Always: use <form action> + useActionState for submissions.
- Very specific: line 320
Never: add useMemo / useCallback / React.memo in new code — the React Compiler handles memoization.
- Distinctive: line 321
Never: use an array index as a key for a dynamic list.
- Very specific: line 323
Never: call hooks conditionally, in loops, or after an early return — top level only.
- Very specific: line 327
Always: put a feature file in its kind folder (components/ hooks/ api/ queries/ schemas/ types/ utils/).
“Common” is measured: kept by at least 6 in 10 of the 23 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React — Components, Hooks, State, Styling
Modern React component, state, effect, and styling patterns. Baseline is React 19.2 + React Compiler v1.0 (stable since October 2025) and Tailwind v4.
Quick Reference — When to Load What
| Working on… | Read |
| Starting a new app, page, or screen | SHADCN.md + TAILWIND-TOKENS.md first — check what the repo already has |
| Splitting components, custom hooks, file size, prop drilling | COMPONENT-DESIGN.md |
| useEffect — whether you even need one, cleanup, dependency arrays | USE-EFFECT.md |
Re-renders, memoization, React Compiler, list keys, <Activity> | PERFORMANCE.md |
| Loading skeletons, empty states, Suspense + error boundary pairing | LOADING-STATES.md |
| Client state stores — Zustand, selectors, middleware, slices | ZUSTAND.md |
| Styling — colors, spacing, design tokens, no arbitrary values | TAILWIND-TOKENS.md |
| Forms — React Hook Form, Zod, field errors, submission state | FORMS.md |
shadcn components — Base UI vs Radix, cva variants, cn(), where files go | SHADCN.md |
Critical Gotchas (Always-Inline)
These are the highest-leverage React 19 mistakes. Memorize them.
1. ref Is a Normal Prop — No forwardRef
// BAD: forwardRef is deprecated in React 19
const Input = forwardRef<HTMLInputElement, InputProps>((props, ref) => (
<input ref={ref} {...props} />
));
// GOOD: ref is just a prop
function Input({ ref, ...props }: InputProps & { ref?: React.Ref<HTMLInputElement> }) {
return <input ref={ref} {...props} />;
}2. <Context> Is the Provider — No .Provider
const ThemeContext = createContext<Theme>("light");
// BAD: .Provider is deprecated
<ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>
// GOOD: render the context itself
<ThemeContext value={theme}>{children}</ThemeContext>3. use() Reads Context and Promises — Conditionally
Unlike useContext, use() works inside if blocks and loops, and unwraps promises with Suspense.
import { use } from "react";
function Panel({ show }: { show: boolean }) {
if (!show) return null;
const theme = use(ThemeContext); // legal inside a conditional
return <hr className={theme} />;
}4. Derive State During Render — Don't Sync It in an Effect
// BAD: extra state + an Effect that lags one render behind
const [filtered, setFiltered] = useState(items);
useEffect(() => setFiltered(items.filter(i => i.active)), [items]);
// GOOD: compute during render — no state, no Effect
const filtered = items.filter(i => i.active);If a value can be computed from props or other state, it is not state. See USE-EFFECT.md.
5. Never Hand-Roll Submission State — RHF by Default, Actions for the Simple Case
The rule is that isSubmitting and per-field errors are never useState. Two
things satisfy it, and which one is not a preference:
React Hook Form + zodResolver is the default. shadcn's <Form> is React
Hook Form, so any form using it is already RHF. See FORMS.md.
const form = useForm({ resolver: zodResolver(Schema), defaultValues: { username: "" } });
// form.formState.isSubmitting — never a useState flaguseActionState for a form with one submit, one error, and no per-field
feedback — a search box, a confirm button. No dependency, uncontrolled inputs.
const [error, submitAction, isPending] = useActionState(
async (_prev: string | null, formData: FormData) => {
const result = await createPost({ title: formData.get("title") as string });
return result.error ?? null;
},
null,
);
return (
<form action={submitAction}>
<input name="title" required />
<button type="submit" disabled={isPending}>{isPending ? "Posting…" : "Create"}</button>
{error && <p className="text-destructive">{error}</p>}
</form>
);Never both on one form — handleSubmit and <form action> both own submission.
6. useFormStatus Reads Form State Without Prop Drilling
A reusable submit button reads its parent <form>'s pending state directly.
import { useFormStatus } from "react-dom";
// GOOD: no isPending prop threaded down
function SubmitButton({ children }: { children: React.ReactNode }) {
const { pending } = useFormStatus();
return <button type="submit" disabled={pending}>{pending ? "Saving…" : children}</button>;
}useFormStatus must be called from a component rendered inside the <form>.
7. useOptimistic for In-Flight UI
const [optimisticMessages, addOptimistic] = useOptimistic(
messages,
(state: Message[], text: string) => [...state, { id: crypto.randomUUID(), text, sending: true }],
);
// call addOptimistic(text) inside the action; React reverts automatically on settle8. Manual useMemo / useCallback / React.memo Is an Anti-Pattern
React Compiler v1.0 is stable and auto-memoizes. Hand-written memo is now boilerplate.
// BAD: noise the compiler already handles
const UserCard = React.memo(({ user }: { user: User }) => {
const name = useMemo(() => formatName(user.name), [user.name]);
const onClick = useCallback(() => selectUser(user.id), [user.id]);
return <button onClick={onClick}>{name}</button>;
});
// GOOD: write it plainly — the compiler memoizes
function UserCard({ user }: { user: User }) {
return <button onClick={() => selectUser(user.id)}>{formatName(user.name)}</button>;
}Three narrow exceptions remain (third-party reference equality, measured-expensive computation, no-compiler codebases). See PERFORMANCE.md.
9. Stable Keys — Never Index Keys for Dynamic Lists
Index keys corrupt state when the list reorders, inserts, or deletes.
// BAD: index key
{todos.map((todo, i) => <TodoItem key={i} todo={todo} />)}
// GOOD: stable identity
{todos.map(todo => <TodoItem key={todo.id} todo={todo} />)}
// GOOD: key to remount-and-reset a subtree on identity change
<ProfileForm key={userId} userId={userId} />10. Don't Initialize State From Props Without Care
// BAD: stale forever — prop changes never update the state
function Editor({ initialText }: { initialText: string }) {
const [text, setText] = useState(initialText);
}If the copy must reset when the prop changes, use a key (gotcha 9). If the parent owns the value, lift state up instead.
11. Rules of Hooks — Call Them at the Top Level
Hooks are tracked by call order. They must run at the top level of a component or custom hook — never inside conditions, loops, or after an early return.
// BAD: hook after an early return — call order changes when `user` is null
function Profile({ user }: { user: User | null }) {
if (!user) return null;
const [tab, setTab] = useState("home"); // skipped on some renders
}
// GOOD: all hooks first, unconditionally; branch afterwards
function Profile({ user }: { user: User | null }) {
const [tab, setTab] = useState("home");
if (!user) return null;
}use() is the only hook that may be called conditionally (gotcha 3). Every other hook — useState, useEffect, useReducer, custom hooks — is top-level only. See USE-EFFECT.md for the full Effect catalog.
When to Use What
| Decision | Use |
| Single value, toggle, form field | useState |
| Multiple related values updated together | useReducer |
| Value computable from props/state | derive during render — not state |
| Read context | use(Context) — never useContext |
| Global, rarely-changing value (theme, auth, locale) | Context |
| Pass UI down 2-3 levels | children / slot props — not Context |
| Form submission | <form action> + useActionState |
| Submit button pending state | useFormStatus |
| Optimistic UI during an action | useOptimistic |
| Non-urgent state update | startTransition |
| Reset a subtree on identity change | key prop |
| Component, hook, or file too large | split — see COMPONENT-DESIGN.md |
| Data fetching | TanStack Query, or use() + Suspense — not a raw Effect |
TypeScript Integration
// Extend HTML element props
interface ButtonProps extends React.ComponentPropsWithoutRef<"button"> {
variant?: "primary" | "secondary" | "destructive";
isLoading?: boolean;
}
// Generic components
interface ListProps<T> {
items: T[];
renderItem: (item: T) => React.ReactNode;
getKey: (item: T) => string;
}
function List<T>({ items, renderItem, getKey }: ListProps<T>) {
return <ul>{items.map(item => <li key={getKey(item)}>{renderItem(item)}</li>)}</ul>;
}
// Event types
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {};
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {};
// Children: always React.ReactNode
interface CardProps { title: string; children: React.ReactNode; }
// Discriminated-union props — make impossible prop combinations unrepresentable
type AlertProps =
| { variant: "inline"; onDismiss?: never }
| { variant: "toast"; onDismiss: () => void }; // a toast REQUIRES onDismissFor general type design — discriminated unions, generics, satisfies, type guards — see the typescript-best-practices skill. This section covers only React-specific typing; hook typing (useState/useReducer/useRef, custom-hook returns, nullable Context) is in COMPONENT-DESIGN.md.
Error Boundaries
Granular, per-section — never one app-wide catch.
import { ErrorBoundary } from "react-error-boundary";
function Dashboard() {
return (
<div>
<ErrorBoundary FallbackComponent={ErrorFallback}><AnalyticsChart /></ErrorBoundary>
<ErrorBoundary FallbackComponent={ErrorFallback}><RecentOrders /></ErrorBoundary>
</div>
);
}Project Structure
One folder per domain. Inside it, every file lives in the folder named for its kind. The only file at a feature's root is index.ts.
src/
features/destinos/
components/ DestinoCard.tsx DestinoCard.test.tsx
hooks/ useGlobe.ts useGlobe.test.ts # not query hooks
api/ destinos.ts destinos.test.ts # fetch + parse, no React
queries/ destinos.ts # queryOptions, useQuery, useMutation
schemas/ destino.ts # zod schemas + their z.infer types
types/ destino.ts # types with no schema
utils/ monthFromUrl.ts monthFromUrl.test.ts
test/ fixtures.ts # fixtures shared by this feature's tests
index.ts # public API only
shared/ same kind folders, for code 2+ features use
routes/ or pages/ # wherever the router wants them; thinBAD features/search/useDismiss.ts hook at the feature root
BAD features/legal/components.test.ts one test file for many components
BAD src/components/DestinoTable.tsx domain component outside its feature
GOOD features/search/hooks/useDismiss.ts
GOOD features/legal/components/LegalPage.test.tsxA test sits next to the file it tests and carries its name; in a project that already keeps tests in __tests__/, follow it. A test of a whole flow goes in src/test/. Create a kind folder when its first file arrives, not before. Import another feature through its index.ts only. Colocate first; move to shared/ when 2+ features need it.
Rules
- Always use function components — no class components.
- Always treat
refas a normal prop; never writeforwardRefin new code. - Always render
<Context value={…}>directly — never<Context.Provider>. - Always use
use()to read context — neveruseContext. - Always derive state during render when a value is computable; don't sync it in an Effect.
- Always use
<form action>+useActionStatefor submissions;useFormStatusfor nested submit buttons. - Never add
useMemo/useCallback/React.memoin new code — the React Compiler handles memoization. See PERFORMANCE.md. - Never use an array index as a key for a dynamic list; use a stable id.
- Never initialize state from a prop expecting it to update — use a
keyreset or lift state up. - Never call hooks conditionally, in loops, or after an early return — top level only.
use()is the sole exception. - Prefer
children/ slot props over Context to avoid prop drilling. - Prefer granular per-section error boundaries; never rely on data-fetching Effects.
- Always handle the loading / error / empty trio in data-driven components — see LOADING-STATES.md.
- Always put a feature file in its kind folder (
components/ hooks/ api/ queries/ schemas/ types/ utils/); never at the feature root, never in a top-levelsrc/components/.
Reference Files
For deeper guidance, load the file matching what you're working on:
- COMPONENT-DESIGN.md — read before writing a new component or hook, and when splitting one or a file is getting large. The question is "how should this be structured?", not "is this file already too big?". Covers the single-responsibility hard limits (≤200 lines/file, ≤30 lines/function, ≤50-line JSX return, ≤5-6 props, ≤3 nesting levels), split vs don't-split signals, one-concern-per-hook plus hook naming, composition vs Context vs prop drilling, early returns, file organization, the complexity smell test, and the server/client component boundary note.
- USE-EFFECT.md — read when writing or reviewing a
useEffect. Covers the full "You Might Not Need an Effect" catalog (transforming data, resetting state viakey, event handling, chained Effects, notifying parents, passing data to a parent, app init, fetching), the decision checklist, when Effects are correct plus cleanup and race-condition (ignore/AbortController) patterns, dependency-array discipline, anduseSyncExternalStore. - PERFORMANCE.md — read when chasing re-renders or memoization. Covers React Compiler v1.0 (delete manual memo; the three narrow exceptions; ESLint enforcement), keys and
startTransition,useDeferredValuewith its React 19 initial-value arg,<Activity mode>for pre-render and keep-alive, and resource preloading (preload/preinit/prefetchDNS/preconnect). - LOADING-STATES.md — read when a component fetches data or shows async UI. Covers the loading / error / empty trio every data component must handle, skeleton screens vs spinners (and avoiding layout shift), building a reusable token-styled
Skeletonprimitive,<Suspense>+ error-boundary pairing and boundary placement, empty-state design, and accessibility (aria-busy,aria-live/role="status", focus management). - ZUSTAND.md — read when client/UI state outgrows
useStateand Context. Covers typed curried store creation, atomic selectors anduseShallowto prevent re-renders, exporting custom hooks over the raw store, event-driven actions,persist/immer/devtoolsmiddleware and composition order, the slices pattern, transient updates, and the rule that server state belongs in a query library, not a store. - FORMS.md — read when building or reviewing a form. Covers React Hook Form with
zodResolverand shadcn's<Form>, why a transforming schema needsuseForm<z.input<S>, unknown, z.output<S>>instead ofz.infer,defaultValuesand the controlled/uncontrolled flip, readingformStateinstead of hand-rolled flags, putting server rejections on the field withsetError, the Zod 3 → 4 differences, and the narrow case whereuseActionStateis the better call. - SHADCN.md — read before writing any UI in a repo that has a
components/ui/directory, including the first screen of a new app, and when adding or editing a shadcn component. The question is "does this repo already have a design system I must use?", not "am I editing a shadcn file?". Covers Base UI as the default since July 2026 and how to tell which primitive a file uses, migrating one component at a time, why you editcomponents/ui/*instead of wrapping it,cvavariants withVariantPropsrather than boolean props,cn()and whytailwind-mergematters for overrides,data-slotfor reaching into a child, theFieldfamily for form layout, and what belongs incomponents/ui/versuscomponents/. - TAILWIND-TOKENS.md — read before writing any
className, including the first one in a new app — picking colors, spacing, radius, or typography. The question is "what tokens does this repo already define?", not "am I restyling something?". Covers Tailwind v4 CSS-first@themeconfig and namespaces, semantic color tokens (never rawred-500),@theme inline, the--color-*: initialnamespace reset for hard palette lockdown, the semantic spacing scale, the ban on arbitrary values (p-[13px],text-[#3a3a3a]) and the narrow exceptions, plus ESLint enforcement tooling.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

