How to use createElement in React JS?


The component function returns the result from the React.createElement method, React can use that HTML element to add content in Domain Object Model (DOM).

Example

import React, { Component } from 'react';
 
export default function App() {
return React.createElement("h1",
       { className: "bg-secondary text-white text-center p-2" },
        "Hello World");
}
Most Helpful This Week