Question: How do you make a webpage interactive?
Answer: When data changes, the UI must change.
Example:
function Counter() {
let count = 0; // Normal variable
return (
<button onClick={() => {
count = count + 1;
console.log(count); // Logs: 1, 2, 3...
}}>
Count: {count} {/* Always shows 0 on screen! */}
</button>
);
}
What happens:
count becomes 1 in memory1 ✅0 ❌Why?