React works in a way that attaches itself to some DOM element. In your case, you are attaching it to some element with id
of root
.
TLDR;
Your index.html will contain the code of your application inside the element with root
id during the runtime in the browser. You can see it by inspecting it using browser developer tools.
Your <App />
is the root of your application and if you use dev tools
of your browser and you inspect the DOM tree you will see components in there. They are just dynamically attached by React (ReactDOM)
and React is in the control of when and how things are rendered.
If your components look something like:
import React from 'react';
function App() {
return <h1 className="title">Hello!</h1>;
}
In Dev tools
your DOM structure will looks something like this:
<div id="root">
<h1 class="title">Hello!</h1>
</div>
Here you can see that you have element with root
id that you attached your <App />
before and you can see the content of <App />
, <h1 class="title" />
together with classes.
That is also how Instagram works and most of the single-page applications or SPAs in short.
There is also a possibility to render static version of your application.