close

[Fixed] Deprecation notice: ReactDOM.render is no longer supported in React 18

Today We are Going To Solve Deprecation notice: ReactDOM.render is no longer supported in React 18 in Reactjs. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix Deprecation notice: ReactDOM.render is no longer supported in React 18 Error?

  1. How to Fix Deprecation notice: ReactDOM.render is no longer supported in React 18 Error?

    To Fix Deprecation notice: ReactDOM.render is no longer supported in React 18 Error just Use createRoot. Here to solve this issue you have to just use createERoot just like below and it will solve the issue. import { createRoot } from 'react-dom/client' createRoot(document.getElementById('root')).render(<h1>Your App</h1>)

  2. Deprecation notice: ReactDOM.render is no longer supported in React 18

    To Fix Deprecation notice: ReactDOM.render is no longer supported in React 18 Error just For React version 18. If you are using React version 18 use it to solve this issue.
    const root = ReactDOM.createRoot(document.getElementById("root")); root.render(<App />);

Solution 1 : Use createRoot

Here to solve this issue you have to just use createERoot just like below and it will solve the issue.

import { createRoot } from 'react-dom/client'
createRoot(document.getElementById('root')).render(<h1>Your App</h1>)

Solution 2 : For React version 18

If you are using React version 18 use it to solve this issue.

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

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

Leave a Comment