React · Middle · Question 8 of 75

When is useCallback actually useful?

Explanation

useCallback by itself doesn't speed up code: the function is still created during render, plus there's the cost of comparing dependencies. It makes sense only if someone cares about a stable reference. The function's size doesn't matter.

Further reading

Problem with a question

React · Middle · question 8

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz