Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactDOM.render is deprecated since React 18.0.0, use createRoot instead, see https://reactjs.org/link/switch-to-createroot #734

Open
philipjonsen opened this issue Sep 22, 2023 · 0 comments

Comments

@philipjonsen
Copy link

DESCRIPTION
The method being used has been deprecated in the latest version of the React Framework and may be removed in the future version. It is recommended to look for an alternative for this to fix this issue.

Here are some deprecated lifecycle methods since v16.9.0:

componentWillMount
componentWillReceiveProps
componentWillUpdate

BAD PRACTICE:
// Example 1
React.render(, root);

// Example 2
React.unmountComponentAtNode(root);

// Example 3
React.findDOMNode(this.refs.foo);

// Example 4
React.renderToString();

// Example 5
React.renderToStaticMarkup();

// Example 6
const propTypes = {
foo: PropTypes.bar,
};

// Example 7
// old lifecycles (since React 16.9)
componentWillMount() { }
componentWillReceiveProps() { }
componentWillUpdate() { }

RECOMMENDED:

// Example 1
ReactDOM.render(, root);

// Example 2
ReactDOM.unmountComponentAtNode(root)

// Example 3
ReactDOM.findDOMNode(this.refs.foo)

// Example 4
ReactDOMServer.renderToString();

// Example 5
ReactDOMServer.renderToStaticMarkup();

// Example 6
import { PropTypes } from 'prop-types';

// Example 7
UNSAFE_componentWillMount() { }
UNSAFE_componentWillReceiveProps() { }
UNSAFE_componentWillUpdate() { }

Problematic react : https://github.com/bloominstituteoftechnology/nasa-photo-of-the-day/blob/main/src/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant