react-patterns
Skill461 starsChanged 3 months agoMITView on GitHub
Modern React patterns and principles. Hooks, composition, performance, TypeScript best practices.
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 32 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 31
Prefer small, focused components
- Distinctive: line 125
Check if actually slow
“Common” is measured: kept by at least 6 in 10 of the 32 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 Patterns
Principles for building production-ready React applications.
1. Component Design Principles
Component Types
| Type | Use | State |
| Server | Data fetching, static | None |
| Client | Interactivity | useState, effects |
| Presentational | UI display | Props only |
| Container | Logic/state | Heavy state |
Design Rules
- One responsibility per component
- Props down, events up
- Composition over inheritance
- Prefer small, focused components
2. Hook Patterns
When to Extract Hooks
| Pattern | Extract When |
| useLocalStorage | Same storage logic needed |
| useDebounce | Multiple debounced values |
| useFetch | Repeated fetch patterns |
| useForm | Complex form state |
Hook Rules
- Hooks at top level only
- Same order every render
- Custom hooks start with "use"
- Clean up effects on unmount
3. State Management Selection
| Complexity | Solution |
| Simple | useState, useReducer |
| Shared local | Context |
| Server state | React Query, SWR |
| Complex global | Zustand, Redux Toolkit |
State Placement
| Scope | Where |
| Single component | useState |
| Parent-child | Lift state up |
| Subtree | Context |
| App-wide | Global store |
4. React 19 Patterns
New Hooks
| Hook | Purpose |
| useActionState | Form submission state |
| useOptimistic | Optimistic UI updates |
| use | Read resources in render |
Compiler Benefits
- Automatic memoization
- Less manual useMemo/useCallback
- Focus on pure components
5. Composition Patterns
Compound Components
- Parent provides context
- Children consume context
- Flexible slot-based composition
- Example: Tabs, Accordion, Dropdown
Render Props vs Hooks
| Use Case | Prefer |
| Reusable logic | Custom hook |
| Render flexibility | Render props |
| Cross-cutting | Higher-order component |
6. Performance Principles
When to Optimize
| Signal | Action |
| Slow renders | Profile first |
| Large lists | Virtualize |
| Expensive calc | useMemo |
| Stable callbacks | useCallback |
Optimization Order
- Check if actually slow
- Profile with DevTools
- Identify bottleneck
- Apply targeted fix
7. Error Handling
Error Boundary Usage
| Scope | Placement |
| App-wide | Root level |
| Feature | Route/feature level |
| Component | Around risky component |
Error Recovery
- Show fallback UI
- Log error
- Offer retry option
- Preserve user data
8. TypeScript Patterns
Props Typing
| Pattern | Use |
| Interface | Component props |
| Type | Unions, complex |
| Generic | Reusable components |
Common Types
| Need | Type |
| Children | ReactNode |
| Event handler | MouseEventHandler |
| Ref | RefObject<Element> |
9. Testing Principles
| Level | Focus |
| Unit | Pure functions, hooks |
| Integration | Component behavior |
| E2E | User flows |
Test Priorities
- User-visible behavior
- Edge cases
- Error states
- Accessibility
10. Anti-Patterns
| ❌ Don't | ✅ Do |
| Prop drilling deep | Use context |
| Giant components | Split smaller |
| useEffect for everything | Server components |
| Premature optimization | Profile first |
| Index as key | Stable unique ID |
Remember: React is about composition. Build small, combine thoughtfully.
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Other versions37 projects use a version of this.
Word for word · 1
- Fandry96/k3-agentic-skills★ 27100% same
Edited · 9
- xenitV1/Antigravity-Workflows★ 13097% same
- VoDaiLocz/kilo-kit-mcp★ 2897% same
- xfstudio/skills★ 997% same
- genfeedai/genfeed.ai★ 482% same
- ai4brands-design/claude-skills★ 297% same
- Ghosteken/agent-harness★ 282% same
- miptah21/skills★ 297% same
- lschGSL/claude_code_template★ 199% same
- MortuisVMain/ai-agent-superpowers★ 093% same
Wrote their own version · 27
- openstory-so/openstory★ 678same name
- jh941213/my-claude-code-asset★ 126same name
- TangleML/tangle-ui★ 104same name
- maxyeh0817/Forge★ 34same name
- komluk/scaffolding★ 15same name
- gongyijie85/dsh-ecc★ 8same name
- jdanigo/hydraia★ 8same name
- Sagargupta16/claude-code-recipes★ 8same name
- Shiven0504/claude-skills-collection★ 6same name
- peopleforrester/claude-dotfiles★ 3same name
17 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.
Used alongsideProjects with it also use typescript-strict, docker-expert and 10 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.
Greg-KleinSkilltypescript-strict
TypeScript strict mode conventions and type safety rules
Also in 3 projects that use this
xfstudioSkilldocker-expert
Docker containerization expert with deep knowledge of multi-stage builds, image optimization, container security, Docker Compose orchestration, and production deployment patterns. Use PROACTIVELY for Dockerfile optimization, container issues, image size problems, security hardening, networking, and orchestration challenges.
Also in 3 projects that use this
BlockSkilltesting-strategy
Guidelines for writing effective tests in this project
Also in 4 projects that use this
etewiahSkille2e-testing
Playwright E2E testing and Lighthouse performance auditing. Use when setting up E2E tests, running Playwright tests, performing Lighthouse audits, or debugging E2E test failures.
Also in 5 projects that use this
LangChainSkilldocker-patterns
Best practices for Docker containerization and multi-stage builds
Also in 3 projects that use this
mstuder-slalomSkillgolang-patterns
Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.
Also in 3 projects that use this
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/react-best-practices/AGENTS.mdAGENTS.md
- .claude/skills/react-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/ymc-agents.mdcCursor rule
- brainstormingSkill
- bun-buildSkill
- bun-developmentSkill
- bun-dev-serverSkill
- bun-initSkill
- bun-testSkill
- bun-win32Skill
- Cli-ExpertSkill
- cli-masterySkill
- create-implementation-planSkill
- planning-with-filesSkill
- powershell-windowsSkill
- react-best-practicesSkill
- react:componentsSkill
- react-patternsSkill
- react-state-managementSkill
- systematic-debuggingSkill
- writing-plansSkill
- ymc-downloadsSkill
- ymc-playbackSkill
- brainstormingSkill
- bun-buildSkill
- bun-developmentSkill
- bun-dev-serverSkill
- bun-initSkill
- bun-testSkill
- bun-win32Skill
- Cli-ExpertSkill
- cli-masterySkill
- create-implementation-planSkill
- planning-with-filesSkill
- powershell-windowsSkill
- react-best-practicesSkill
- react:componentsSkill
- react-state-managementSkill
- systematic-debuggingSkill
- writing-plansSkill
- ymc-downloadsSkill
- ymc-playbackSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

