react-19-patterns
БесплатноЗапускает вложенные скриптыНе проверенComprehensive React 19 patterns including all hooks, Server/Client Components, Suspense, streaming, and transitions. Ensures correct React 19 usage with…
от aiskillstore★ 509 звёзд на GitHubОб этом скилле
React 19 Patterns - Comprehensive Guide
When to Use This Skill
Use this skill when:
- Writing React components (Server or Client)
- Using React hooks (standard or new React 19 hooks)
- Implementing forms with Server Actions
- Working with Suspense and streaming
- Managing state and transitions
- Optimistic UI updates
- Migrating from React 18 to React 19
What This Skill Covers
Core Patterns
- Server vs Client Components - Complete decision tree
- All React Hooks - Complete reference with TypeScript
- Suspense Patterns - Boundaries, streaming, error handling
- Server Components - Data fetching, caching, composition
- Client Components - Interactivity, state, effects
- Transitions - useTransition, startTransition, isPending
- Streaming - Progressive rendering patterns
- Migration Guide - React 18 → React 19
New in React 19
use()- For async data in componentsuseOptimistic()- For optimistic UI updatesuseFormStatus()- For form submission stateuseActionState()- For Server Action state- Enhanced
useTransition()- Better performance - Improved error boundaries
- Better hydration
Quick Reference
Server Component Pattern
// ✅ Default - async data fetching
export default async function ProjectsPage() {
const projects = await db.project.findMany()
return <ProjectList projects={projects} />
}
Client Component Pattern
// ✅ Use 'use client' for interactivity
'use client'
import { useState } from 'react'
export function InteractiveComponent() {
const [count, setCount] = useState(0)
return <button onClick={() => setCount(count + 1)}>{count}</button>
}
New React 19 Hook Pattern
'use client'
import { useOptimistic } from 'react'
export function TodoList({ todos }: Props) {
const [optimisticTodos, addOptimisticTodo] = useOptimistic(
todos,
(state, newTodo: string) => [...state, { id: 'temp', text: newTodo, pending: true }]
)
return (
<form action={async (formData) => {
addOptimisticTodo(formData.get('todo'))
await createTodo(formData)
}}>
<input name="todo" />
<button type="submit">Add</button>
</form>
)
}
File Structure
This skill is organized into detailed guides:
- server-vs-client.md - Decision tree for component type
- hooks-complete.md - All React hooks with TypeScript
- suspense-patterns.md - Suspense boundaries and streaming
- server-components-complete.md - Server Component patterns
- client-components-complete.md - Client Component patterns
- transitions.md - useTransition and concurrent features
- streaming-patterns.md - Progressive rendering
- migration-guide.md - React 18 → 19 migration
- validate-react.py - Validation tool for React rules
Decision Flow
START: Creating new component
│
├─ Does it need interactivity (onClick, onChange)?
│ ├─ YES → Read client-components-complete.md
│ └─ NO → Continue
│
├─ Does it need React hooks (useState, useEffect)?
│ ├─ YES → Read client-components-complete.md + hooks-complete.md
│ └─ NO → Continue
│
├─ Does it fetch data?
│ ├─ YES → Read server-components-complete.md
│ └─ NO → Continue
│
└─ Default → Server Component (read server-components-complete.md)
Need specific hook help?
└─ Read hooks-complete.md (complete reference)
Need Suspense/streaming?
└─ Read suspense-patterns.md + streaming-patterns.md
Need optimistic UI?
└─ Read hooks-complete.md (useOptimistic section)
Need form handling?
└─ Read hooks-complete.md (useFormStatus, useActionState)
Migrating from React 18?
└─ Read migration-guide.md
Common Mistakes Prevented
❌ Async Client Component
'use client'
export default async function Bad() {} // ERROR!
✅ Use Server Component or useEffect
// Option 1: Server Component
export default async function Good() {} // ✅
// Option 2: Client with useEffect
'use client'
export default function Good() {
useEffect(() => {
fetchData()
}, [])
}
❌ Hooks in Conditions
if (condition) {
useState(0) // ERROR: Rules of Hooks violation
}
✅ Hooks at Top Level
const [value, setValue] = useState(0)
if (condition) {
// Use the hook result here
}
❌ Browser APIs in Server Component
export default function Bad() {
const data = localStorage.getItem('key') // ERROR!
return <div>{data}</div>
}
✅ Use Client Component
'use client'
export default function Good() {
const [data, setData] = useState(() =>
localStorage.getItem('key')
)
return <div>{data}</div>
}
Validation
Use validate-react.py to check your React code:
# Validate single file
python .claude/skills/react-19-patterns/validate-react.py src/components/Button.tsx
# Validate directory
python .claude/skills/react-19-patterns/validate-react.py src/components/
# Auto-fix (where possib
Установить react-19-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWebFetchBashВложенные файлы
FAQ
Что делает скилл react-19-patterns?
Comprehensive React 19 patterns including all hooks, Server/Client Components, Suspense, streaming, and transitions. Ensures correct React 19 usage with TypeScript.
Как установить скилл react-19-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react-19-patterns запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic