React Elements: Updating the Rendered Element

function tick() {
  const element = (
    <div>
      <h1>Hello, world!</h1>
      <h2>It is {new Date().toLocaleTimeString()}.</h2>
    </div>
  );
  ReactDOM.render(element, document.getElementById('root'));
}

setInterval(tick, 1000);

The only way to update the UI is to create a new element, and pass it to ReactDOM.render().

Related concepts

Updating the Rendered Element

React Elements: Updating the Rendered Element — Structure map

Clickable & Draggable!

React Elements: Updating the Rendered Element — Related pages: