Hooks

Published May 29, 2025 by kuvi41
Code Snippets
Hooks

🔁 Top Custom & Built-in React Hooks You’ll Use Every Day

Hooks simplify logic sharing in React and React Native. Here’s a must-know collection:

✅ Built-in Hooks

  • useState: State management
  • useEffect: Lifecycle and side effects
  • useMemo: Performance optimization
  • useRef: DOM ref and persistent value

🧩 Common Custom Hooks

  • useDebounce: Debounce API calls / inputs
  • useLocalStorage: Persist state in browser
  • useOnClickOutside: Detect outside clicks (for modals, menus)
  • useMediaQuery: Detect screen width / responsive design
  • useCopyToClipboard: One-click copy action

📦 Libraries

  • react-use: 100+ hooks
    npm i react-use
  • usehooks-ts: Type-safe hooks for TS
    npm i usehooks-ts
  • ahooks (Alibaba): Production-grade utilities
    npm i ahooks