Getting Started

If you load React from a <script> tag, these top-level APIs are available on the React global


React Elements

React elements are the building blocks for creating a React application.
A React element is not the same as an HTML (or DOM) element.
A React element is an object representation of a HTML element.
To create a React element use the createElement method.

React.createElement( 
  type,
  [props],
  [...children]
)

The type argument can be either a tag name string (such as 'div' or 'span'),
a React component type (a class or a function), or a React fragment type.

// Without JSX 
var rElement = React.createElement('h1', null, 'Hello World');
var dElement = document.getElementById('app');
ReactDOM.render(rElement, dElement);

// Using JSX
var rElement = <h1>Hello World</h1>;
var dElement = document.getElementById('app');
ReactDOM.render(rElement, dElement);

A React element is stateless.
React elements live in the Virtual DOM.



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