Loading...

React gives us a declarative way to build user interfaces instead of manually updating the UI step by step like we do with the DOM in JavaScript. We simply declare what we want the UI to look like, and React takes care of updating it.
Declarative means telling a system what the result should be. Imperative means telling it how to do something, step by step.
In vanilla JavaScript, we write imperative code — specifying exactly how and when elements should show, hide, enable, or update by manipulating the DOM manually.
In React, we do not directly manipulate the DOM. Instead, we declare what we want to see based on state.
Here are the steps to think about UI declaratively:
'typing' | 'submitting' | 'success'.In React, UI changes are driven by state changes. By identifying all possible states, storing them clearly, and updating UI based on state, we can build predictable and stable interfaces.
For a deeper dive, check the official docs: https://react.dev/learn/reacting-to-input-with-state