Class components and migration

componentWillUnmount

Release resources when the instance is removed; do not queue state updates during teardown.

Formal Syntax & Structure

react syntaxreact
componentWillUnmount() { this.dispose?.(); }

Working Example

Example Snippetreact
componentWillUnmount() { this.dispose?.(); }
React Reference