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.

Top comments (0)