Rendering to DOM

React provides the ReactDOM.render() function from react-dom js that can be used to render React nodes to the DOM. We’ve already seen this render() function in use in this chapter.

In the example below, using ReactDOM.render(), the <option> and <foo-bar> React nodes are rendered to the DOM.

See the Pen xjJBeQ by Bunlong (@Bunlong) on CodePen.

Once rendered to the DOM, the HTML will be:

<body>
  <div id="app1"><option value="1" data-reactid=".0">one</option></div>
  <div id="app2"><foo-bar classname="bar" children="foo" data-reactid=".1">foo</foo-bar></div>
</body>

The ReactDOM.render() function is initially how you get the React nodes to the Virtual DOM, then to the HTML DOM.

Updated: