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

React v18 doesn't support ReactDOM anymore. #17

Open
GustaveRw opened this issue Aug 2, 2022 · 1 comment
Open

React v18 doesn't support ReactDOM anymore. #17

GustaveRw opened this issue Aug 2, 2022 · 1 comment

Comments

@GustaveRw
Copy link

No description provided.

@GustaveRw GustaveRw changed the title React v18 does support ReactDOM anymore. React v18 doesn't support ReactDOM anymore. Aug 2, 2022
@Mudassir55
Copy link

The reason is ReactDOM.render is no longer supported in React 18.

Earlier, react used to render the component in below way

ReactDOM.render(, document.getElementById('root'))
using React 18, we should start using createRoot() instead of render()

Example

ReactDOM.createRoot(document.getElementById('root')).render()
The render() method of the react-dom package is considered legacy starting react-dom version 18.

The method is replaced with the createRoot() method that is exported from react-dom/client.

The createRoot() method takes the root element as a parameter and creates a React root.

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

2 participants