react-patterns
/react-patterns
Essential React patterns for hooks, components, and state management. Use when building React components, implementing custom hooks, or debugging state management issues. Covers useState, useEffect, useCallback, useMemo, and context patterns.
- Author
- adilkalam ↗
- Repository
- orca ↗
- Licence
- MIT
- Last repository change
- 31.07.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 31.07.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Essential React patterns for hooks, components, and state management. Use when building React components, implementing custom hooks, or debugging state management issues. Covers useState, useEffect, useCallback, useMemo, and context patterns.
Original author description
Essential React patterns for hooks, components, and state management. Use when building React components, implementing custom hooks, or debugging state management issues. Covers useState, useEffect, useCallback, useMemo, and context patterns.
How it works
- Custom Hook Patterns
- Component Patterns
- Performance Patterns
- Anti-Patterns to Avoid
SKILL.md preview
---
name: react-patterns
description: >
Essential React patterns for hooks, components, and state management.
Use when building React components, implementing custom hooks, or debugging
state management issues. Covers useState, useEffect, useCallback, useMemo,
and context patterns.
---
# React Patterns
## Custom Hook Patterns
### useDebounce
```typescript
function useDebounce<T>(value: T, delay: number): T {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const handler = setTimeout(() => setDebouncedValue(value), delay);
return () => clearTimeout(handler);
}, [value, delay]);
return debouncedValue;
}
```
### useLocalStorage
```typescript
function useLocalStorage<T>(key: string, initialValue: T) {
const [storedValue, setStoredValue] = useState<T>(() => {
try {
const item = window.localStorage.getItem(key);
return item ? JSON.parse(item) : initialValue;
} catch {
return initialValue;
}
});
const setValue = (value: T | ((val: T) => T)) => {
const valueToStore = value instanceof Function ? value(storedValue) : value;
setStoredValue(valueToStore);
window.localStorage.setItem(key, JSON.stringify(valueToStore));
};
return [storedValue, setValue] as const;
}
```
## Component Patterns
### Compound Components
```tsx
const Tabs = ({ children }: { children: React.ReactNode }) => {
const [activeIndex, setActiveIndex] = useState(0);
return (
<TabsContext.Provider value={{ activeIndex, setActiveIndex }}>
{children}
</TabsContext.Provider>
);
};
Tabs.Tab = ({ index, children }) => {
const { activeIndex, setActiveIndex } = useContext(TabsContext);
return (
<button
onClick={() => setActiveIndex(index)}
data-active={activeIndex === index}
>
{children}
</button>
);
};
```
### Render Props
```tsx
const MouseTracker = ({ render }: { render: (pos: {x: number, y: number}) => React.ReactNode }) => {
const [position, setPosition] = useState({ x: 0, y: 0 });
useEffect(() => {
const handleMove = (e: MouseEvent) => setPosition({ x: e.clientX, y: e.clientY });
window.addEventListener('mousemove', handleMove);
return () => window.removeEventListener('mousemove', handleMove);
}, []);
return <>{render(position)}</>;
};
```
## Performance Patterns
### Memoization
- Use `useMemo` for expensive computations
- Use `useCallback` for callback stability
- Use `React.memo` for component memoization
- Always check if memoization is actually needed (profile first)
### Code Splitting
```tsx
const HeavyComponent = lazy(() => import('./HeavyComponent'));
function App() {
return (
<Suspense fallback={<Loading />}>
<HeavyComponent />
</Suspense>
);
}
```
## Anti-Patterns to Avoid
1. **State in useEffect deps that triggers the effect** - leads to infinite loops
2. **Missing cleanup functions** - causes memory leaks
3. **Deriving state from props without key** - use `key` prop to reset
4. **Overusing Context** - creates unnecessary re-renders
5. **useState for derived values** - use useMemo instead
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · adilkalam/orca | 100 | MIT |
| ahmet-cetinkaya/dotfiles | 100 | MIT |
| Sanit-mann/The-Insectoids | 100 | MIT |
| komluk/scaffolding | 100 | MIT |
| affaan-m/ECC | 100 | MIT |
| nokri-mohammed/claude-team | 100 | MIT |
| claude-dev-suite/claude-dev-suite | 100 | MIT |
| reddygopalkrishna/developer-agent-skills | 100 | MIT |
| SHRIJANAGAIN/Nemo-Cli | 100 | Apache-2.0 |
Database snapshot: 13.11.2026 · package version 83106c96610b (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 91react-hooks-patterns
Use when React Hooks patterns including useState, useEffect, useContext, useMemo, useCallback, and custom hooks. Use for modern React development. - 100react-hooks-patterns
Use this skill when implementing custom hooks or managing side effects with useState, useEffect, useMemo, useCallback, and useRef in React. - 100react-hooks
React Hooks patterns, rules, and custom hook development. Covers all built-in hooks (useState, useEffect, useContext, etc.), performance hooks, and patterns for creating reusable custom hooks. USE WHEN: user mentions "custom hooks", "hook rules", "useState", "useEffect",… - 100react-expert
Expert modern React (18/19): hooks, component design, state, performance, and Server Components. Trigger keywords: React, hooks, useState, useEffect, useMemo, useCallback, useRef, context, re-render, key, Suspense, Server Components, RSC, JSX, stale closure. Use when… - 100react
React 18+ library for building user interfaces. Covers components, hooks, state management, and rendering patterns. USE WHEN: user mentions "React component", "useState", "useEffect", "hooks", asks about "building UI", "component lifecycle", "React rendering", "JSX" DO NOT USE… - 100react-ops
React development patterns, hooks, state management, Server Components, and performance optimization. Use for: react, hooks, useState, useEffect, jsx, tsx, server components, RSC, zustand, react query, component patterns, react testing library, error boundary, suspense, react 19.