You already felt it in the JavaScript module. Let's name it — then see how React makes it disappear.
Remember the vanilla Notes app? Every time the data changed, you had to rebuild the HTML and redraw the list:
// the vanilla JS way — you manage the DOM by hand
function render() {
list.innerHTML = ""; // wipe
notes.forEach(n => { // rebuild
const li = document.createElement("li");
li.textContent = n.text;
list.appendChild(li);
});
}
addBtn.addEventListener("click", () => {
notes.push(newNote);
render(); // ← you must remember to call this EVERY time
});
render() and the screen silently shows stale data. In a big app with dozens of things changing, hand-syncing the DOM becomes a nightmare of bugs.React flips it around. You write a function that says "for this data, the UI looks like this". When the data changes, React re-runs your function and updates only what actually changed — automatically.
"Find the list. Clear it. Loop the notes. Make an li for each. Append them. …and remember to redo all that on every change."
"The list is the notes mapped to items." You state the relationship once; React keeps the screen matching the data.
// React: describe what the UI IS for the given notes
function NoteList({ notes }) {
return (
<ul>
{notes.map(n => <li key={n.id}>{n.text}</li>)}
</ul>
);
}
// change notes → React re-renders. No manual DOM code, ever.
render() by hand every time — easy to forget, and the source of many bugs.