This is basically the
for a React application into the browser’s DOM. It has 2 arguments:
The first argument is WHAT to render to the browser. This is always a “React element”.
The second argument is WHERE to render that React element in the browser. This has to be a valid DOM node that exists in the statically rendered HTML. The example above uses a special
element which exists in the playground’s display area (the first
is used for the native version).
What exactly is a React element? It’s a VIRTUAL element describing a DOM element. It’s what the
API method returns.
Check more information on
Instead of working with strings to represent DOM elements (as in the native DOM example above) in React we represent DOM elements with
using calls to the
method. These objects are known as React elements.
function has many arguments:
The first argument is the HTML “tag” for the DOM element to represent, which is
in this example.
The second argument is for any attributes (like
, etc.) we want the DOM element to have. The simple
we’re using has no attributes, so we used
The third argument is the content of the DOM element. We’ve put a “Hello React” string in there. The optional third argument and all the optional arguments after it form the
list for the rendered element. An element can have 0 or more children.