DEV Community

charles Kamande
charles Kamande

Posted on

Basics to React and Rendering Components

React is a JavaScript library used for building dynamic user interfaces, primarily for web applications. It enables developers to create reusable UI components and efficiently update the DOM using a virtual DOM mechanism.

Rendering Components on the DOM
To render a React component on the DOM, follow these steps:

  1. Import React and ReactDOM: (in jsx file) import React from "react"; import ReactDOM from "react-dom";
  2. Create a Component:
    This is how you create a simple Component in jsx:

    function App() {
    return

    Hello, React!

    ; }
  3. To render the above Component to the DOM do the below:

ReactDOM.createRoot(document.getElementById("root")).render();

Note this ensures the App component is rendered inside the

in the HTML file.

References

Top comments (0)