React · Senior · Question 48 of 75
How does React 18+ handle setState on an unmounted component?
- ✓Correct answer: It ignores it: the old warning was removed as a false positive
- 2It throws an exception and unmounts the entire app
- 3It stores the value and applies it on the next mount
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.