react/no-is-mounted
Disallow the removed legacy isMounted() API — cancel async work instead of guarding setState.
- Category: Correctness
- Severity: warn
- Source:
oxlint-builtin:react - Framework: global
- Enabled when: always (unless customRulesOnly=true)
- Documentation: https://oxc.rs/docs/guide/usage/linter/rules/react/no-is-mounted.html
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Fires on this.isMounted() calls inside React class components (React.Component subclasses and createReactClass factories). The legacy isMounted() API was removed and is universally treated as an anti-pattern — it was used to silence "Can't call setState on an unmounted component" warnings while masking real subscription/listener leaks. The rule is scoped to React class bodies, so an unrelated class with its own isMounted method is not a false positive.
Fix prompt
Use this once validation confirms the diagnostic is real.
Cancel the async work instead of guarding setState: use an AbortController for fetch, unsubscribe in componentWillUnmount, or return a cleanup function from useEffect. If you must track mount state, set this._isMounted in componentDidMount and clear it in componentWillUnmount as a temporary shim until you migrate the class to a function component with hooks. See https://oxc.rs/docs/guide/usage/linter/rules/react/no-is-mounted.html
Related rules
More Correctness rules from the rules reference:
react/no-render-return-value: Disallow using the return value of ReactDOM.render — a legacy escape hatch removed in React 19.react/no-string-refs: Disallow legacy string refs like ref='node' — use createRef, useRef, or callback refs.react/no-unknown-property: Disallow unknown or mis-cased DOM attributes in JSX, like class instead of className.react/require-render-return: Require class component render() methods to return a value — a missing return renders nothing.react/rules-of-hooks: Enforce the Rules of Hooks: call hooks only at the top level of components and custom hooks, never in conditions or loops.