Skip to content
Home
Dev Convert Generate Finance Calc Design Security Media

More categories

Productivity 23 SEO Tools 18 Network Tools 17 Text Tools 16 Education Tools 15 PDF Tools 11 Mockups 9

Learn and build

GuidesBlogAPI & MCPCheatsheetsChangelog All categories

Browse

439 tools · 15 categories

Start here

Popular tools New this week 11 All tools 439

Categories

Developer Tools 91 Converters 65 Calculators 32 Finance Tools 32 Generators 31 Media Tools 27 Design Tools 25 Security Tools 25 Productivity 23 SEO Tools 18 Network Tools 17 Text Tools 16 Education Tools 15 PDF Tools 11 Mockups 9

Learn and build

Guides Cheatsheets Blog REST API MCP server Changelog

No matches here.

Keep FindUtils free Sponsors fund new tools
  1. Cheatsheets
Guides Blog API & MCP
Sponsor
FindUtils
Sponsor
  1. Home
  2. Cheatsheets
  3. Web Development
  4. React Hooks

Web Development · Cheatsheet

React Hooks Cheatsheet

useState, useEffect, useRef, useMemo, React 19 hooks, and custom hook patterns

53 commands 9 sections

On this sheet

State Hooks 7 Effect Hooks 6 Ref Hooks 6 Context Hook 4 Performance Hooks 6 Actions, IDs & External Data 6 Custom Hook Patterns 8 Rules & Best Practices 6 Sources 4

No entry matches that filter.

State Hooks

  • const [value, setValue] = useState(initial) Declare state variable with initial value
  • setValue(newValue) Replace state with new value
  • setValue(prev => prev + 1) Update state based on previous value
  • useState(() => expensiveComputation()) Lazy initializer; development Strict Mode can call it twice
  • const [state, dispatch] = useReducer(reducer, init) State with reducer pattern
  • dispatch({ type: "INCREMENT" }) Dispatch action to reducer
  • useReducer(reducer, arg, createInit) Lazy reducer initialization

Effect Hooks

  • useEffect(() => { ... }) Run the effect after each committed render
  • useEffect(() => { ... }, []) Set up on mount; development Strict Mode adds a setup and cleanup check
  • useEffect(() => { ... }, [dep]) Run effect when dep changes
  • useEffect(() => { return () => cleanup(); }, []) Clean up on unmount; development Strict Mode also checks cleanup
  • useLayoutEffect(() => { ... }) Run synchronously after DOM mutations
  • useInsertionEffect(() => { ... }) Inject styles before layout (CSS-in-JS)

Ref Hooks

  • const ref = useRef(null) Create mutable ref object
  • ref.current Access current ref value
  • <input ref={ref} /> Attach ref to DOM element
  • const countRef = useRef(0) Store value without re-renders
  • useImperativeHandle(ref, () => ({ focus })) Customize ref exposed to parent
  • forwardRef((props, ref) => <input ref={ref} />) Forward ref to child component

Context Hook

  • const ctx = createContext(defaultValue) Create a context object
  • <MyContext.Provider value={data}> Provide context value to children
  • const value = useContext(MyContext) Consume nearest context value
  • useContext(ThemeContext) ?? "light" Fallback for missing provider

Performance Hooks

  • const memoized = useMemo(() => compute(a, b), [a, b]) Memoize expensive computation
  • const handler = useCallback((e) => { ... }, [dep]) Memoize callback function
  • const [isPending, startTransition] = useTransition() Mark state update as non-urgent
  • startTransition(() => setSearchQuery(input)) Defer a non-urgent update
  • const deferredValue = useDeferredValue(value) Defer re-render for a value
  • memo(Component) Skip re-render if props unchanged

Actions, IDs & External Data

  • const data = use(promise) Unwrap promise or context
  • const [state, action, isPending] = useActionState(fn, init) Form action with pending state
  • const [optimistic, setOptimistic] = useOptimistic(state) Optimistic UI updates
  • const { pending } = useFormStatus() Form submission pending state
  • useId() Generate unique ID for accessibility
  • useSyncExternalStore(subscribe, getSnapshot) Subscribe to external data store

Custom Hook Patterns

  • function useLocalStorage(key, init) { ... } Persist state to localStorage
  • function useDebounce(value, delay) { ... } Debounce rapidly changing values
  • function useFetch(url) { ... } Data fetching with loading state
  • function useMediaQuery(query) { ... } Respond to CSS media queries
  • function useClickOutside(ref, handler) { ... } Detect clicks outside element
  • function usePrevious(value) { ... } Track previous render value
  • function useInterval(callback, delay) { ... } Declarative setInterval wrapper
  • function useToggle(initial = false) { ... } Boolean toggle state

Rules & Best Practices

  • Keep hooks at the top level; use is an exception The use API permits conditions and loops. Hooks such as useState and useEffect do not.
  • Only call hooks from React functions Components or custom hooks only
  • Name custom hooks with "use" prefix useXxx naming convention required
  • List all dependencies in the array Omitting deps causes stale closures
  • Avoid objects/arrays as deps (use primitives) Reference equality causes extra runs
  • Cleanup effects to prevent memory leaks Return cleanup function from useEffect

Sources

  • https://react.dev/reference/react React API reference: hooks, context, and component APIs.
  • https://react.dev/reference/react/useEffect React useEffect: dependencies, cleanup, and development Strict Mode.
  • https://react.dev/reference/react/use React use: promise and context handling, including conditions and loops.
  • https://react.dev/reference/react/useState React useState: initializer behavior and development checks.

Related cheatsheets

  • CSS Flexbox36 commands
  • CSS Grid36 commands
  • HTTP Status Codes41 commands

Guides that use these commands

  • Tailwind to StyleX Migration: Convert and Review Token FilesGuide · 8 min read
  • Tailwind to StyleX Token Guide: Mapping and ValidationGuide · 5 min read

From FindUtils

More to explore

Products and services from the team behind FindUtils.

Promote your tool
Featured product seeranks.com SeeRanks — transparent product discovery A public ranking board where paid placement is always labeled and every product keeps its earned position. View SeeRanks Public rank board #1 Sponsored #2 #3 #4 Paid placement is always labeled Free favicon tool emojifavicons.com Emoji Favicons Turn any emoji into a favicon with one HTML line. SVG, PNG or ICO, no sign-up. <link rel="icon" href=".../🦊.svg"> Create a favicon
FindUtils service findutils.com Articles for software tools A sourced article for your channels, or a sponsored FindUtils publication with editorial review. Compare packages Domain portfolio findutils.com Domain names for sale .com.dev.sh.app.io Unused names across dev tools, AI, PDF and commerce. Make an offer. Browse the list Playable ranking towerscore.io TowerScore — stack the skyline Play to climb, or buy a floor. Paid floors are labeled. Open TowerScore

Missing a tool you need?

Tell us what to build next. Most requests ship as a free browser tool, an API endpoint and an MCP tool.

Request a tool
FindUtils

Free, fast utilities. Most tools process your files in the browser; lookup tools say what they send, and pages load analytics and ads.

  • No sign-up for free tools
  • Most tools run in your browser
  • 369 tools on the REST API, 369 on MCP

Tools

DevelopersConvertPDFDesignSecurityAll tools →

Learn

GuidesBlogCheatsheetsChangelog

Build

REST APIMCP serverAPI referenceWorkflowsStatus

FindUtils

AboutLibraries we useSponsorRequest a toolDomains for saleContact
© 2026 FindUtils PrivacyTermsSitemap
Service status
FindUtils

Free, fast utilities that respect your data. Most tools run in your browser.

Build with it

REST APIMCP serverGuidesChangelog

FindUtils

AboutSponsorPrivacyContact
Theme
© 2026 FindUtils Terms
FindUtils
Guides Blog REST API MCP server Changelog

Categories

Developers 91 Convert 65 Calculate 32 Finance 32 Generate 31 Media 27
All 15 categories →

Keep it free

Sponsorship keeps every tool free and funds the new ones we ship each week.

Sponsor Back the project
Tools API Sponsor