Hint
Declarative UI library — describe what the UI should look like, not how to update it
React is a JavaScript library for building user interfaces. It solves the problem of keeping the UI in sync with application state.
Core ideas:
// Imperative (jQuery style) — how to update
const btn = document.getElementById('btn');
btn.addEventListener('click', () => {
const count = parseInt(btn.textContent) + 1;
btn.textContent = count;
});
// Declarative (React style) — what it should look like
function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
}