Search⌘ K

Reviewing React hooks

Explore key React hooks like useState, useEffect, useMemo, and useContext to manage state and side effects effectively. Understand how to create custom hooks by combining built-in hooks, enabling reusable logic and cleaner code structure in your React projects.

Overview of React hooks

We have seen quite a few hooks provided by React. Let's take a moment to review what we have learned so far:

  • Update a state with the useState hook.useState_hook

  • Handle a side effect with the useEffect hook.useEffect_hook

  • Reuse the last value with the useMemo hook.useMemo_Hook

  • Update an area with the useContext hook.useContext_Hook

  • Hide stuff from display with the useRef hook.useRef_Hook

Beyond explored hooks

The preceding hooks aren't the entire React collection of hooks. In fact, React has more than a dozen built-in hooks; to name some others: useCallback, useLayoutEffect, useTransition, and useDeferredValue, and some of them are also in the experimental stage for the future concurrent mode of React.

There's one thing unique about the hooks we have covered so far. Each hook is unique and each is designed for an atomic purpose. There's not much overlapping in between. This provides a solid foundation when we want to mix and match them in our application.

When it ...