1. The Fundamental Problem

Question: How do you make a webpage interactive?

Answer: When data changes, the UI must change.

Example:


2. Why Normal Variables Don't Work

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:

  1. Click button → count becomes 1 in memory
  2. Console shows 1
  3. But UI still shows 0

Why?