Performance: What is React
MEDIUM IMPACT
React affects how quickly a web page can show interactive content by efficiently updating the parts of the page that change.
import React, { useState } from 'react'; function App() { const [data, setData] = useState(''); return <div>{data}</div>; } export default App;
const element = document.getElementById('app'); element.innerHTML = '<div>' + newData + '</div>';
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct DOM manipulation replacing full content | High (full subtree replaced) | 1 full reflow per update | High paint cost | [X] Bad |
| React virtual DOM with selective updates | Low (only changed nodes) | Minimal reflows | Lower paint cost | [OK] Good |