Next useCallback

    0

    0

    Jose Romero

    nextcallbackuseCallbackβ€’β€’β€’
    NextJS Javascript 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

    import { useCallback } from "react";
    
    const memoizedCallback = useCallback(() => {
        doSomething(dependencies);
      },
      [dependencies],
    ); 
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.