react-patterns
Skill104 starsChanged 3 days agoApache-2.0View on GitHub
React and React Compiler patterns for this project. Use when writing React components, hooks, providers, or working with React Compiler compatibility.
We split this skill into the rules it gives an agent
21 rules. 0 are common, 13 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 32 edited versions we read keep these.
13
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 10
Use functional components with hooks exclusively (no class components)
- Distinctive: line 11
Use proper dependency arrays in useEffect
- Distinctive: line 12
Follow the existing component structure
- Distinctive: line 13
Use React 19 features and patterns
- Distinctive: line 36
Use proper TypeScript return types
- Very specific: line 37
Follow existing patterns in src/hooks/
- Distinctive: line 58
Use Tanstack Query for server state
- Distinctive: line 59
Use Tanstack Router for routing
- Distinctive: line 60
Use React hooks for local component state
- Very specific: line 61
Use Context providers for app-wide state (see existing providers in src/providers/)
- Distinctive: line 96
Follow Rules of Hooks strictly: - no conditional hooks, no hooks in loops, proper dependency arrays
- Very specific: line 99
Don't spread props with {...props} unnecessarily
- Distinctive: line 100
Avoid dynamic property access on objects when possible
- Distinctive: line 101
Keep component logic predictable
- Very specific: line 105
When a file is added to react-compiler.config.js:
- Very specific: line 107
Remove unnecessary useCallback and useMemo (compiler handles this)
- Very specific: line 108
Verify no compiler violations with pnpm run validate
- Distinctive: line 109
Test the component still works correctly
- Very specific: line 110
Consolidate entries by folder: when all files in a directory are compiler-enabled (e.g., use /path/to/folder instead of listing each file …
- Very specific: line 123
If you encounter existing useMemo/useCallback/memo in a file, remove them when the file is enabled in react-compiler.config.js
- Distinctive: line 125
Follow existing patterns for optimization
“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
Core Rules
- Use functional components with hooks exclusively (no class components)
- Use proper dependency arrays in useEffect
- Follow the existing component structure
- Use React 19 features and patterns
- Import modules from React:
import module from react. Do not use inlineReact.[module]
Component Structure
// ComponentName/ComponentName.tsx — import directly, no index.ts barrel
interface ComponentNameProps {
...
}
export const ComponentName = ({ }: ComponentNameProps) => {
...
return (
...
);
};Custom Hooks
- Prefix with
use - Return objects for multiple values, not arrays
- Use proper TypeScript return types
- Follow existing patterns in
src/hooks/
Provider Pattern
const Context = createContext<ContextType | null>(null);
export const Provider = ({ children }: { children: ReactNode }) => {
...
return <Context.Provider value={value}>{children}</Context.Provider>;
};
export const useContext = () => {
const context = useContext(Context);
if (!context) throw new Error('useContext must be used within Provider');
return context;
};State Management
- Use Tanstack Query for server state
- Use Tanstack Router for routing
- Use React hooks for local component state
- Use Context providers for app-wide state (see existing providers in
src/providers/) - Use
useRequiredContextto simplify context usage and avoid null checks
React Compiler
This project uses the React Compiler for automatic memoization. Files/directories are incrementally adopted in react-compiler.config.js.
Writing React Compiler Compatible Code
For new files, ensure they follow React Compiler rules from the start:
Don't mutate values during render
// Bad - mutating during render const items = props.items; items.push(newItem); // Good - create new reference const items = [...props.items, newItem];Don't read/write refs during render
// Bad - reading ref during render const value = myRef.current; return <div>{value}</div>; // Good - read refs in effects or callbacks useEffect(() => { const value = myRef.current; }, []);- Follow Rules of Hooks strictly - no conditional hooks, no hooks in loops, proper dependency arrays
- Avoid patterns the compiler can't optimize
- Don't spread props with
{...props}unnecessarily - Avoid dynamic property access on objects when possible
- Keep component logic predictable
- Don't spread props with
Adding Files to React Compiler
When a file is added to react-compiler.config.js:
- Remove unnecessary
useCallbackanduseMemo(compiler handles this) - Verify no compiler violations with
pnpm run validate - Test the component still works correctly
- Consolidate entries by folder when all files in a directory are compiler-enabled (e.g., use
/path/to/folderinstead of listing each file individually)
React Compiler Config Structure
Files are organized by cleanup effort in react-compiler.config.js:
- Top section: Already enabled directories/files
- Middle: Ready to enable (0 useCallback/useMemo)
- Bottom (commented): Need cleanup before enabling
Performance
- Do not use
useMemo,useCallback, ormemomanually — the React Compiler handles memoization automatically - If you encounter existing
useMemo/useCallback/memoin a file, remove them when the file is enabled inreact-compiler.config.js - Lazy load heavy components when possible
- Follow existing patterns for optimization
Other versions36 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 36
- openstory-so/openstory★ 693same name
- involvex/youtube-music-cli★ 468same name
- xenitV1/Antigravity-Workflows★ 130same name
- maxyeh0817/Forge★ 34same name
- VoDaiLocz/kilo-kit-mcp★ 28same name
- Fandry96/k3-agentic-skills★ 27same name
- komluk/scaffolding★ 15same name
- xfstudio/skills★ 9same name
- gongyijie85/dsh-ecc★ 8same name
- jdanigo/hydraia★ 8same name
26 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 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.
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
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
MicrosoftSkillapi-design
Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.
Also in 8 projects that use this
In this repository20 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- accessibilitySkill
- address-pr-commentsSkill
- analytics-trackingSkill
- audit-ticketsSkill
- docs-updateSkill
- e2e-testingSkill
- gardeningSkill
- list-skillsSkill
- open-sourceSkill
- project-conventionsSkill
- reviewSkill
- tangle-domainSkill
- tanstack-querySkill
- tanstack-routerSkill
- typescript-standardsSkill
- ui-primitivesSkill
- validateSkill
- vitest-testingSkill
- playwright-testingSkill
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.

