State Management · Junior · Question 5 of 75

How do you remove an item with id from an array in state?

Explanation

State must be updated immutably: filter, map, spread and toSorted create a new array. splice and delete mutate the existing one, the reference stays the same, and React skips the update.

Further reading

Problem with a question

State Management · Junior · question 5

Test yourself

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

Take this quiz