The React declarative model means you describe what the UI should look like for a given state, and React figures out how to make the UI match that description.
You don’t tell React how to update the DOM step by step — you tell it what the UI should be.
You manually describe every step:
const button =document.querySelector("button");
button.disabled =true;
button.textContent ="Loading...";
| Aspect | Declarative (React Model) | Imperative (Vanilla JavaScript) |
|---|---|---|
| Focus | What the final UI should be (the desired result). | How to achieve the result (step-by-step instructions). |
| DOM | Abstracts away direct DOM manipulation. You use JSX to describe components. | Requires manual selection and modification of specific DOM elements (e.g., document.createElement, element.appendChild). |
| Updates | React uses a Virtual DOM to compare the new and old UI descriptions and apply only necessary changes. | The developer must explicitly write code to handle all possible updates, additions, and removals for every state change. |
| Analogy | Telling a butler, "I want dinner with chicken". | Giving a butler detailed instructions: "Go to the kitchen, open the fridge, remove the chicken...". |
React handles:
You describe the desired UI:
<button disabled={isLoading}>
{isLoading ?"Loading..." :"Submit"}
</button>



containment + specialization in action


generic components
specialization
containment

String Literals
**// children** prop in **MyComponent** will be simply the string “Little Lemon”
<MyComponent>Little Lemon</MyComponent>
// each div below also returns "Little Lemon"
// JSX removes white space and blank lines
<div> Little Lemon </div>
<div>
Little Lemon
</div>
<div>
Little Lemon
</div>
// JSX turns new line in middle of string into space
<div>
Little
Lemon
</div>
JSX Elements
// provide JSX elements as children to display nested components
<Alert>
<Title />
<Body />
</Alert>
// JSX enables mixing and matching diff types of children
<Alert>
<div>Are you sure?</div>
<Body />
</Alert>
React Fragments - group list of children without adding extra nodes to DOM
// explicit component imported from React
return (
<React.Fragment>
<li>Pizza margarita</li>
<li>Pizza diavola</li>
</React.Fragment>
);
// empty tags - shorter syntax for fragment
return (
<>
<li>Pizza margarita</li>
<li>Pizza diavola</li>
</>
);
JavaScript Expressions - pass as children by enclosing with {}
// these expressions are identical
<MyComponent>Little Lemon</MyComponent>
<MyComponent>{'Little Lemon'}</MyComponent>
// helpful when rendering list of JSX elements of arbitrary length
function Dessert(props) {
return <li>{props.title}</li>;
}
function List() {
const desserts = ['tiramisu', 'ice cream', 'cake'];
return (
<ul>
{desserts.map((dessert) => <Item key={dessert} title={dessert} />)}
</ul>
);
}
// mix JavaScript expressions with other types of children
function Hello(props) {
return <div>Hello {props.name}!</div>;
}
Functions