Render HTML Elements to the DOM - React 18

The challenge

Alongside doing challenges on freeCodeCamp, I also try to setup React (using CDN links) on my local machine (just to know how to do everything outside of fCC). I ran into a problem with the apparently new React 18, which fCC doesn’t seem to be using:

ReactDOM.render(JSX, document.getElementById('root'))

throws an error:

Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it’s running React 17. Learn more: How to Upgrade to React 18 – React

I try following the link they provided but since I barely started React, I didn’t understand how to update to ‘createRoot’.

How do I update? I don’t know anything about npm and whatnot either. Should I just revert back to using React 17?

It all depends on your local settings and how are you planning to run your project locally.

But React has an official guide to add it easily on any web page without using npm. You should check it out, I think it can help you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.