React·100 questions

What is useCallback and how does it differ from useMemo?

Answer
useCallback caches a function.
useMemo caches a value.
useCallback(fn, deps) ~= useMemo(() => fn, deps).
Useful for passing callbacks to memo components.
Do not overuse: it also has overhead.
Was this answer helpful?

More questions in this topic

Related questions from other topics