React 19 Patterns with Compiler

VerifiedSafe

Covers React 19 patterns with React Compiler: automatic memoization, named imports, server components, use() hook, useActionState, and ref as prop. Helps you write idiomatic React 19 code by following the latest best practices and avoiding explicit memoization. Triggered when working with .tsx files using React 19 features.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude CodeCursorWindsurf
#react-19#react-compiler#hook-patterns#optimization#server-components

Recommended for

Automated summary

Provides patterns for React 19 components using the React Compiler, covering automatic memoization, server components, the use() hook, actions, and ref as prop.

Strengths

  • Eliminates manual memoization with React Compiler.
  • Promotes server components as default.
  • Introduces new hooks like use() and useActionState for simpler async handling.
  • Simplifies ref passing without forwardRef.

Limitations

  • Requires React 19 and React Compiler setup.
  • Not backward compatible with older React versions.
  • Some patterns like use() are still experimental in some environments.
When to use it

Use when building new React 19 applications or migrating existing codebases that can adopt React Compiler.

When not to use it

Avoid when working with projects that cannot upgrade to React 19 or do not have React Compiler enabled.

Security analysis

Safe
Quality score90/100

The skill provides React 19 coding patterns and best practices. It does not instruct execution of any commands, tools, or actions that could harm systems or exfiltrate data. The allowed-tools list is standard but the skill itself only recommends code patterns, not system-level operations.

No concerns found

How this analysis is made

Examples

Refactor component to use React Compiler
Rewrite this React component to follow React 19 patterns: remove all useMemo and useCallback calls, use named imports, and ensure it's a server component if possible.
Convert to useActionState for form handling
Update this form component to use the new useActionState hook from React 19 for managing submission state.
Refactor forwardRef to use ref as prop
Remove the forwardRef wrapper from this component and pass ref directly as a prop instead, as per React 19.

name: react-19 description: > React 19 patterns with React Compiler. Trigger: When writing React 19 components/hooks in .tsx (React Compiler rules, hook patterns, refs as props). If using Next.js App Router/Server Actions, also use nextjs-15. license: Apache-2.0 metadata: author: Alan version: "1.0" scope: [root, ui] auto_invoke: "Writing React components" allowed-tools: Read, Edit, Write, Glob, Grep, Bash, WebFetch, WebSearch, Task

No Manual Memoization (REQUIRED)

// ✅ React Compiler handles optimization automatically
function Component({ items }) {
  const filtered = items.filter(x => x.active);
  const sorted = filtered.sort((a, b) => a.name.localeCompare(b.name));

  const handleClick = (id) => {
    console.log(id);
  };

  return <List items={sorted} onClick={handleClick} />;
}

// ❌ NEVER: Manual memoization
const filtered = useMemo(() => items.filter(x => x.active), [items]);
const handleClick = useCallback((id) => console.log(id), []);

Imports (REQUIRED)

// ✅ ALWAYS: Named imports
import { useState, useEffect, useRef } from "react";

// ❌ NEVER
import React from "react";
import * as React from "react";

Server Components First

// ✅ Server Component (default) - no directive
export default async function Page() {
  const data = await fetchData();
  return <ClientComponent data={data} />;
}

// ✅ Client Component - only when needed
"use client";
export function Interactive() {
  const [state, setState] = useState(false);
  return <button onClick={() => setState(!state)}>Toggle</button>;
}

When to use "use client"

  • useState, useEffect, useRef, useContext
  • Event handlers (onClick, onChange)
  • Browser APIs (window, localStorage)

use() Hook

import { use } from "react";

// Read promises (suspends until resolved)
function Comments({ promise }) {
  const comments = use(promise);
  return comments.map(c => <div key={c.id}>{c.text}</div>);
}

// Conditional context (not possible with useContext!)
function Theme({ showTheme }) {
  if (showTheme) {
    const theme = use(ThemeContext);
    return <div style={{ color: theme.primary }}>Themed</div>;
  }
  return <div>Plain</div>;
}

Actions & useActionState

"use server";
async function submitForm(formData: FormData) {
  await saveToDatabase(formData);
  revalidatePath("/");
}

// With pending state
import { useActionState } from "react";

function Form() {
  const [state, action, isPending] = useActionState(submitForm, null);
  return (
    <form action={action}>
      <button disabled={isPending}>
        {isPending ? "Saving..." : "Save"}
      </button>
    </form>
  );
}

ref as Prop (No forwardRef)

// ✅ React 19: ref is just a prop
function Input({ ref, ...props }) {
  return <input ref={ref} {...props} />;
}

// ❌ Old way (unnecessary now)
const Input = forwardRef((props, ref) => <input ref={ref} {...props} />);

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/react-19-patterns-with-compiler-mmk3nhkk/download' --output '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md.part' && mv '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md.part' '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Edit, Write, Glob, Grep, Bash, WebFetch, WebSearch, Task

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md' && test -s '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/react-19' && cp -R '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk' '.claude/skills/react-19'

Cursor
test -f '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md' && test -s '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/react-19' && cp -R '.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk' '.cursor/skills/react-19'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/react-19-patterns-with-compiler-mmk3nhkk'

openskills read 'react-19-patterns-with-compiler-mmk3nhkk'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/react-19-patterns-with-compiler-mmk3nhkk/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills