react/no-deprecated

Disallow React APIs that are deprecated

React warns about a deprecated API for a while and then removes it. ReactDOM.render logs a warning in React 18 and no longer exists in React 19, so code that still calls it breaks on upgrade. The report names the version that deprecated the API and what to use instead.

Some of the APIs the rule knows:

DeprecatedSinceUse
ReactDOM.render, ReactDOM.hydrate18.0.0createRoot, hydrateRoot
ReactDOM.unmountComponentAtNode18.0.0root.unmount
ReactDOMServer.renderToNodeStream18.0.0renderToPipeableStream
componentWillMount, componentWillReceiveProps, componentWillUpdate16.9.0the same name with UNSAFE_ in front
React.DOM15.6.0the react-dom-factories package
React.PropTypes, React.createClass15.5.0the prop-types and create-react-class packages

The rule checks member access, named imports and destructuring from require().

If you set settings.react.version ([lint.settings.react] in bunfig.toml, or settings in an ESLint config), an API that was deprecated in a later version isn't reported. Without that setting, the rule reports everything it knows.

Configure#

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"react/no-deprecated" = "error" # or "warn"

Examples#

Reported:

import ReactDOM from "react-dom";

ReactDOM.render(<App />, document.getElementById("root"));
import { hydrate } from "react-dom";

const { unmountComponentAtNode } = require("react-dom");

class Profile extends React.Component {
  componentWillMount() {
    this.load();
  }
}

Not reported:

import { createRoot } from "react-dom/client";

createRoot(document.getElementById("root")).render(<App />);

class Profile extends React.Component {
  componentDidMount() {
    this.load();
  }
}