React Element

A React element is a JavaScript object describing a DOM node (HTML element) and its properties.

There are two ways to create a React element.

The createElement method

function App() {
  return React.createElement("h1", null, "Hello React!");
}

export default App;

The general syntax is:

React.createElement(/* type */, /* props */, /* content */);

The JSX method

function App() {
  return <h1>Hello React!</h1>;
}

export default App;

JSX is a syntax extension to JavaScript that allows us to mix JavaScript with HTML.

We will use JSX in this course.