1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Cache Computed Values for Better Performance with the useMemo React Hook

    reactReact

    If you have a React component that is computing a value that is expensive to compute, then you can cache that value with the useMemo hook, so that it's only re-computed when one of its dependencies change.

    In this lesson, we'll use useMemo to memoize (cache) a label that is computed when the user presses a button - but we'll prevent it from being computed when the user updates other parts of the state (an input text value in this case).