← React Beginner Questions - Set 1 Q6
React Beginner Questions - Set 1
You cannot see the virtual DOM, but you can prove it exists by watching what React actually touches when state changes.
import { useState } from 'react';
export default function Ticker() {
const [count, setCount] = useState(0);
return (
<div>
<p>Static text — never re-created in the DOM</p>
<button onClick={() => setCount(c => c + 1)}>Count: {count}</button>
</div>
);
}
// In DevTools: inspect the <p>. After many clicks its DOM node
// stays identical, while the button's text node is the one updated.