Element Factories

React does provide some built-in shortcuts for creating commonly used HTML element nodes.
These shortcuts are called element factories.
An element-factory is a function that generates a ReactElement with a particular type property.

ReactDOM.render( 
   React.createElement("div", { className: "test" },
      React.createElement("h1", null, "My Heading")
      React.createElement("p", null, "Some Text"}
   ),
   document.getElementById("myapp")
)

is equivalent to this javascript code

ReactDOM.render( 
   React.DOM.div(
      {id : 'test' },
      React.DOM.h1(null, 'My Heading'),
      React.DOM.p(null, 'Some Text')
   ),
   document.getElementById("myapp")
)


© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext