Performance: Creating first React app
MEDIUM IMPACT
This affects the initial page load speed and time to interactive by controlling how React and its dependencies load and render the app.
import React from 'react'; import { createRoot } from 'react-dom/client'; function App() { return <h1>Hello, React!</h1>; } const container = document.getElementById('root'); const root = createRoot(container); root.render(<App />);
import React from 'react'; import ReactDOM from 'react-dom'; function App() { return <h1>Hello, React!</h1>; } ReactDOM.render(<App />, document.getElementById('root'));
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| ReactDOM.render (legacy) | Single root node | 1 reflow | Low paint cost | [!] OK |
| createRoot.render (modern) | Single root node | 1 reflow | Low paint cost | [OK] Good |