React · Senior · Question 48 of 75

How does React 18+ handle setState on an unmounted component?

Explanation

The warning "Can't perform a React state update on an unmounted component" was removed in React 18: it often fired falsely (e.g. on a request response after leaving the page), and real leaks are forgotten subscriptions, not setState itself. You still need to cancel requests and unsubscribe in cleanup.

Further reading

Problem with a question

React · Senior · question 48

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