0
When should you use useMemo vs useCallback?
subina kallyani
easy
2completed
18
Answer
useMemo(fn, deps)caches the result of a computation.useCallback(fn, deps)caches the function reference.
If you’re memoizing expensive calculations → useMemo.
If you’re passing stable function props to children to avoid re-renders → useCallback.
Example:
const expensive = useMemo(() => calculate(data), [data]); const handleClick = useCallback(() => doSomething(id), [id]);
Click to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0