Introduction
How does designing your own component in React end up rendering an actual UI in your browser? Even though when you check View Source, your component's code don’t appear at all?
That’s because React follows a specific rendering flow. Once you understand that flow, everything starts to click. So let’s go behind the scenes and see how it all works under the hood.
1. We all know that an App Starts with index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description"content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
Code snippet 1: index.html
When I run the React app and view the page source (right-click on the page and select "View Page Source"), I see the following code. Everything looks exactly like index.html except for one change: there's an extra line added (highlighted below).

Image 1: View source of index.html
2. The App Loads the bundle.js File
<script defer src="/static/js/bundle.js"></script>
What is it doing?
- It includes your entire React app, all your JavaScript files compiled into one bundle.
- The defer attribute tells the browser: "Download this script but wait to run it until the HTML is parsed".
That bundle file contains your index.js, App.js, and everything else you wrote! This means I don't have to manually add index.js; React includes it automatically during the build process.
3. index.js Takes Control
Inside your bundle.js, React starts at src/index.js.
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
reportWebVitals();
Code snippet 2: index.js
Let’s walk through what’s happening step by step.
Imports
- React and ReactDOM are imported to build and render the UI.
- index.css applies global styles (optional).
- The app is the root component of your application.
- reportWebVitals is used to measure app performance (optional).
Now the code,
const root = ReactDOM.createRoot(document.getElementById('root'));
document.getElementById('root') selects the <div> from index.html, see line 18 in Code Snippet 1.
React uses JavaScript to dynamically inject your UI after the page loads. The index.html file is just a shell, the actual UI gets injected into.
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
- root.render(<App />) renders your App component into the DOM. Everything inside <App /> gets turned into real HTML.
- <React.StrictMode> doesn’t affect what’s shown on screen but helps catch bugs and warns about deprecated APIs during development.
reportWebVitals();
This function can be used to log or send performance metrics (like load time) to an analytics endpoint.
4. React Renders the App Component: App.js
Here's what your App.js file looks like.
import Header from './components/Header';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
Code snippet 3: App.js
This file defines a React component, a JavaScript function that returns JSX (JavaScript XML), which looks like HTML but is processed by JavaScript.



Join the conversation! Your thoughts help the community grow.