AI Hints
Home›React Tutorial›Cheat Sheets
React · Lesson 113 of 120

Cheat Sheet: Hooks

The essentials.

⏱ 2 min read▶ Video at 1:33:08🎓 Free
Watch this lesson in the React courseWatch on YouTube ↗Full React course

Now the hooks. Each one has a single job. Here's when to reach for which.

  • Hooks
  • One job each
  • Which one when

Core hooks

Use state remembers a value that's shown. Use reducer handles complex updates with actions. Use effect syncs with the outside world. Use ref remembers without re-rendering, or points at an element. And use context reads shared values.

HookJob
useStateremember a shown value
useReducercomplex updates, actions
useEffectsync with outside
useRefno re-render, or an element
useContextread shared values

Performance and React 19

Use memo caches a slow calculation, and use callback a function. Use transition and use deferred value keep things responsive. Use action state runs form actions, use optimistic shows instant results, and use reads promises and context.

HookJob
useMemo / useCallbackcache values / functions
useTransitionnon urgent updates
useDeferredValuea lagging copy
useActionStateform actions
useOptimisticinstant feedback
usepromises and context

Summary

Every hook has one job. Pick the one that matches yours. Next, common patterns.

Key takeaways
  • State
  • Effects
  • Refs
Next up: Common Patterns — recipes