We instantiate React elements using the
React.createElement API. Typically, we call this API using JSX elements, but it's also possible to call it directly.
The function signature is:
createElement(type, props, children).
Let's take a quick peek at the internals of a React element tree. The exact details of the element tree aren't important to understand right now, but it's useful to get the gist of how React works.
In this example, we instantiate a few React components using JSX and then print their value to the console.
props object may contain arbitrary properties, e.g.
foo, plus a
children property containing nested React elements. The
children property is somewhat special, since it's created automatically from the nested JSX elements in our code.
Now that we know how React elements work, we can try rendering them to the DOM using React DOM.