Skip to content
Skills Library
Programming · Building & coding

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.

Repository
orca ↗
Licence
MIT
Last repository change
31.07.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 31.07.2026, without references to retired models or APIs.

Licence

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

  1. Custom Hook Patterns
  2. Component Patterns
  3. Performance Patterns
  4. Anti-Patterns to Avoid
Original SKILL.md headings · 111 lines, 348 words
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

RepositoryScoreLicence
This page · adilkalam/orca100MIT
ahmet-cetinkaya/dotfiles100MIT
Sanit-mann/The-Insectoids100MIT
komluk/scaffolding100MIT
affaan-m/ECC100MIT
nokri-mohammed/claude-team100MIT
claude-dev-suite/claude-dev-suite100MIT
reddygopalkrishna/developer-agent-skills100MIT
SHRIJANAGAIN/Nemo-Cli100Apache-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.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.