React · Senior · Question 72 of 75

What does Immer's produce give you for deeply nested state updates?

setState(produce((draft) => { draft.users[3].address.city = "Lviv"; }));

Explanation

Manual spreads for deep paths are verbose and error-prone. Redux Toolkit uses Immer internally; use-immer offers a hook version.

Further reading

Problem with a question

React · Senior · question 72

Test yourself

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

Take this quiz