Comment

Comment by ShellfishMeme

useCallback makes sure that you don't recreate a function you need in a component at every re-render but only when its dependencies change. It returns a function.

useMemo returns a value which is the result of calling the function it is given once the dependencies change.

So useCallback is basically useMemo called with a function that returns a function.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton