React Custom Hooks
React custom hooks cheat sheet with patterns for state management, data fetching, debounce, and reusable logic with code examples.
Other React Sheets
Custom Hook Fundamentals
Learn the fundamentals of creating reusable custom hooks, from basic patterns to advanced composition techniques
Creating Custom Hooks
Master the art of creating reusable custom hooks for state management, side effects, and logic encapsulation
Advanced Hook Patterns
Explore advanced patterns including hook composition, factory hooks, and complex state management
Data Fetching Hooks
Build robust data fetching hooks with loading states, error handling, caching, and request cancellation
API Integration Hooks
Build production-ready data fetching hooks with caching, error handling, retries, and optimistic updates
Utility & Performance Hooks
Create utility hooks for common tasks like local storage, debouncing, and performance optimization
Performance Optimization Hooks
Optimize React app performance with debouncing, throttling, memoization, and lazy loading hooks
Browser & Storage Hooks
Sync React state with localStorage, media queries, and theme
useLocalStorage
State that persists to localStorage with cross-tab sync
useMediaQuery
Subscribe to a CSS media query — responsive logic in JS
Interaction & Lifecycle Hooks
Practical hooks for debounce, click-outside, event listeners, and prior values
useDebouncedValue & useDebouncedCallback
Debounce a changing value or a callback — search inputs, autosave
useClickOutside & useEventListener
Dismiss menus/popovers and attach typed event listeners safely
usePrevious & useIsFirstRender
Track the previous value of a variable, detect the first render
useIntersectionObserver
Detect when an element enters the viewport — lazy load, infinite scroll