To display a React component, use the render function from ReactDOM.
Steps:
Create the Component:
function MyComponent() {
return <h1>Hello from MyComponent</h1>;
}
Render it to the DOM:
import React from 'react';
import ReactDOM from 'react-dom/client';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<MyComponent />);