-3

I'm learning about hooks in React, but I have a doubt, in useEffect an action is executed only once (if there is no change in dependencies), but in useCallback it is also like this, useCallback allows executing a function only once too, if on re-rendering the dependencies are not changed. So what's the difference in them in regards to that.

A clear explanation of the differences between useEffect and useCallback

  • 1
    `useCallback` does *not execute* the function! It's `useMemo` but for functions. – Bergi Aug 07 '23 at 22:25
  • _"useEffect is a React Hook that lets you synchronize a component with an external system."_ and _"useCallback is a React Hook that lets you cache a function definition between re-renders."_ https://react.dev/reference/react/ – evolutionxbox Aug 07 '23 at 22:33

0 Answers0