ID: jsx-react/no-deprecated
Language: JavaScript
Severity: Warning
Category: Error Prone
Description
As React evolves, methods are deprecated over time. This rule warns you about deprecated methods.
Non-Compliant Code Examples
React.render(<MyComponent />, root);
React.unmountComponentAtNode(root);
React.findDOMNode(this.refs.foo);
React.renderToString(<MyComponent />);
React.renderToStaticMarkup(<MyComponent />);
React.createClass({ /* Class object */ });
//Any factories under React.DOM
React.DOM.div();
import React, { PropTypes } from 'react';
// old lifecycles (since React 16.9)
componentWillMount() { }
componentWillReceiveProps() { }
componentWillUpdate() { }
// React 18 deprecations
import { render } from 'react-dom';
ReactDOM.render(<div></div>, container);
import { hydrate } from 'react-dom';
ReactDOM.hydrate(<div></div>, container);
import { unmountComponentAtNode } from 'react-dom';
ReactDOM.unmountComponentAtNode(container);
import { renderToNodeStream } from 'react-dom/server';
ReactDOMServer.renderToNodeStream(element);
Compliant Code Examples
import { PropTypes } from 'prop-types';
UNSAFE_componentWillMount() { }
UNSAFE_componentWillReceiveProps() { }
UNSAFE_componentWillUpdate() { }
ReactDOM.createPortal(child, container);
import { createRoot } from 'react-dom/client';
const root = createRoot(container);
root.unmount();
import { hydrateRoot } from 'react-dom/client';
const root = hydrateRoot(container, <App/>);
Seamless integrations. Try Datadog Code Analysis