React · Middle · Question 5 of 75

What is useMemo for?

Explanation

useMemo(() => filterTodos(todos, tab), [todos, tab]) recomputes the value only when dependencies change. The second use is a stable object reference for memo children or effect dependencies. React may discard the cache, so useMemo is an optimization, not a guarantee.

Further reading

Problem with a question

React · Middle · question 5

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