react-patterns
Skill3 starsChanged 7 months agoMITView on GitHub
React 19+ best practices and patterns. Covers hooks, composition, server components, performance optimization, and state management. Use when building React components or reviewing React code.
Files
React Patterns
Modern React 19+ patterns and best practices.
Component Patterns
Composition Over Prop Drilling
// Compose with children instead of passing many props
<Card>
<Card.Header>
<Card.Title>User Profile</Card.Title>
</Card.Header>
<Card.Body>
<UserInfo user={user} />
</Card.Body>
<Card.Footer>
<Button onClick={save}>Save</Button>
</Card.Footer>
</Card>Render Props for Flexibility
interface ListProps<T> {
items: T[];
renderItem: (item: T, index: number) => ReactNode;
keyExtractor: (item: T) => string;
}
function List<T>({ items, renderItem, keyExtractor }: ListProps<T>) {
return (
<ul>
{items.map((item, i) => (
<li key={keyExtractor(item)}>{renderItem(item, i)}</li>
))}
</ul>
);
}Hook Patterns
Custom Data Fetching Hook
function useQuery<T>(key: string, fetcher: () => Promise<T>) {
const [state, setState] = useState<{
data: T | null;
error: Error | null;
isLoading: boolean;
}>({ data: null, error: null, isLoading: true });
useEffect(() => {
let cancelled = false;
setState(prev => ({ ...prev, isLoading: true }));
fetcher()
.then(data => { if (!cancelled) setState({ data, error: null, isLoading: false }); })
.catch(error => { if (!cancelled) setState({ data: null, error, isLoading: false }); });
return () => { cancelled = true; };
}, [key]);
return state;
}useCallback for Stable References
const handleSubmit = useCallback(
async (data: FormData) => {
await api.submit(userId, data);
onSuccess();
},
[userId, onSuccess]
);useMemo for Expensive Computations
const sortedItems = useMemo(
() => [...items].sort((a, b) => a.name.localeCompare(b.name)),
[items]
);State Management
Local State First
// Start simple
const [isOpen, setIsOpen] = useState(false);
// Graduate to useReducer for complex state
const [state, dispatch] = useReducer(cartReducer, initialCart);
// Context for cross-component state
const ThemeContext = createContext<Theme>('light');Server State (React Query / SWR)
const { data, isLoading } = useQuery({
queryKey: ['users', userId],
queryFn: () => fetchUser(userId),
staleTime: 5 * 60 * 1000,
});Performance
Code Splitting
const Dashboard = lazy(() => import('./Dashboard'));
function App() {
return (
<Suspense fallback={<Skeleton />}>
<Dashboard />
</Suspense>
);
}Virtualization for Long Lists
import { useVirtualizer } from '@tanstack/react-virtual';
function VirtualList({ items }: { items: Item[] }) {
const parentRef = useRef<HTMLDivElement>(null);
const virtualizer = useVirtualizer({
count: items.length,
getScrollElement: () => parentRef.current,
estimateSize: () => 50,
});
return (
<div ref={parentRef} style={{ overflow: 'auto', height: 400 }}>
{virtualizer.getVirtualItems().map(row => (
<div key={row.key} style={{ transform: `translateY(${row.start}px)` }}>
{items[row.index].name}
</div>
))}
</div>
);
}Error Boundaries
class ErrorBoundary extends Component<Props, { hasError: boolean }> {
state = { hasError: false };
static getDerivedStateFromError() {
return { hasError: true };
}
render() {
if (this.state.hasError) return this.props.fallback;
return this.props.children;
}
}Checklist
- Functional components only (no class components for new code)
- Custom hooks for reusable stateful logic
- Correct dependency arrays in useEffect/useCallback/useMemo
- Error boundaries at route level
- Loading and error states handled for async data
- Accessibility: ARIA labels, keyboard navigation, focus management
- Code splitting for route-level components
- Keys use stable, unique identifiers (not array index)
Other versions37 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 37
- openstory-so/openstory★ 678same name
- involvex/youtube-music-cli★ 461same name
- xenitV1/Antigravity-Workflows★ 130same name
- jh941213/my-claude-code-asset★ 126same name
- TangleML/tangle-ui★ 104same name
- maxyeh0817/Forge★ 34same name
- Fandry96/k3-agentic-skills★ 27same name
- VoDaiLocz/kilo-kit-mcp★ 26same name
- komluk/scaffolding★ 15same name
- xfstudio/skills★ 9same name
27 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
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
ElasticSkillaccessibility
Accessibility guidance for Kibana. Use this skill when working with or reviewing EUI components, resolving a11y-related (@elastic/eui) ESLint issues, and ensuring proper use of ARIA attributes, focus management, keyboard interactions, and accessible naming conventions.
Also in 5 projects that use this
In this repository72 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- api-designerSkill
- backend-patternsSkill
- code-reviewerSkill
- debugging-assistantSkill
- golang-testingSkill
- project-guidelines-exampleSkill
- python-testingSkill
- refactoring-guideSkill
- spec-driven-developmentSkill
- tdd-workflowSkill
- verification-loopSkill
- update-docsSkill
- api-docsSkill
- changelog-writerSkill
- readme-generatorSkill
- django-patternsSkill
- django-securitySkill
- django-tddSkill
- django-verificationSkill
- fastapi-patternsSkill
- nextjs-patternsSkill
- springboot-patternsSkill
- springboot-securitySkill
- springboot-tddSkill
- branch-strategySkill
- changelogSkill
- commit-helperSkill
- pr-creatorSkill
- prSkill
- evolveSkill
- instinct-exportSkill
- instinct-importSkill
- instinct-statusSkill
- cleanupSkill
- lint-fixSkill
- refactor-cleanSkill
- update-depsSkill
- continuous-learningSkill
- continuous-learning-v2Skill
- eval-harnessSkill
- iterative-retrievalSkill
- strategic-compactSkill
- golang-patternsSkill
- python-patternsSkill
- rust-patternsSkill
- typescript-patternsSkill
- accessibility-checkerSkill
- build-fixSkill
- code-reviewSkill
- e2eSkill
- performance-reviewerSkill
- security-auditorSkill
- security-reviewSkill
- test-coverageSkill
- checkpointSkill
- deploySkill
- evalSkill
- The first 60 shown.
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.

