import { useCallback } from "react";
      
      const memoizedCallback = useCallback(() => {
          doSomething(dependencies);
        },
        [dependencies],
      );
      Typescript language logo
      your recipe card header background

      Next useCallback

      next
      callback
      useCallback
      ...
      Next TypeScript recipes

      Returns a memoized callback.

      Pass an inline callback and an array of dependencies. useCallback will return a memoized version of the callback that only changes if one of the dependencies has changed. This is useful when passing callbacks to optimized child components that rely on reference equality to prevent unnecessary renders (e.g. shouldComponentUpdate).

      Library: next

      Shortcut: next.hook.callback.use

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.