ReactDOM.render is no longer supported in React 18

If you are using ReactDOM.render() in your React 18 app, you will definitely see the below issue.

ReactDOM.render is no longer supported in React 18

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

Earlier, we used to render the component in below way

ReactDOM.render(<NavBar />, document.getElementById('root'))

If we are using React 18, we should start using createRoot() instead of render()

Example

ReactDOM.createRoot(document.getElementById('root')).render(<NavBar />)

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.

Happy Coding!

Next js experiment

Tried out an app with Next js with the help of an YouTube tutorial video. The app contains basic features like loading data from external api, single level routing, nested routing, layout templates, Hyperlink navigations, Card styles. Here is an outcome. https://next-experiment-six.vercel.app

Thanks @traversymedia

This video is really helpful. https://youtube.com/watch?v=mTz0GXj8NN0&ab_channel=TraversyMedia…

I shall try the Udemy course as well shortly.

Deployed the source in vercel by following the official docs steps. Live: https://next-experiment-six.vercel.app

Its quick and straight forward. I’m yet to figure out – how to trigger the build & deployment in vercel on each commit or merge.

Planning to add footer and some real-time data + images to see on how image rendering & optimisations happening.

#nextjs#react#vercel

Reference

Source of this app is available in the following path

https://github.com/PandiyanCool/next-experiment