DEV Community

Banele1999
Banele1999

Posted on

Learn React with Me. Pt 1

Image description

Rendering the Root Component and Strict Mode

import React from "react";
import ReactDOM from "react-dom/client";

function App() {
    return <h1>Hello React</h1>
}


// Render items in the DOM using react 18
const root = ReactDOM.createRoot(document.getElementById
    ("root"));      //id root is from the index.html
    root.render(
    <React.StrictMode>
        <App />
    </React.StrictMode>);   //Wrapping the component with strict mode.
Enter fullscreen mode Exit fullscreen mode
  • The root element refers to the top-level element that is the parent of all other components in your application. It is typically represented as a DOM node within the public/index.html file that serves as the entry point for your React app.
  • StrictMode is a tool for highlighting potential problems in an application. Like Fragment, StrictMode does not render any visible UI. It activates additional checks and warnings for its descendants.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay