import { useMemo } from "react";
      
      const memoizedValue = useMemo(() => { 
        return computeExpensiveValue(dependency1, dependency2) 
      }, [dependency1, dependency2]);

      Typescript language logoReact useMemo

      react
      hook
      memo
      ...
      React TypeScript Recipes

      Returns a memoized value.

      Pass a β€œcreate” function and an array of dependencies. useMemo will only recompute the memoized value when one of the dependencies has changed. This optimization helps to avoid expensive calculations on every render.

      Shortcut: react.hook.memo.use

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.