Stop 10 · React BasicsTopics · 1/11

Why Use a Framework

Part of the Web Development Roadmap

In short

Your to-do app worked with plain JavaScript. Now imagine it with filters, edit mode, user accounts and twenty screens. Frameworks exist because updating the page by hand stops scaling very quickly.

As apps grow, updating the DOM by hand gets messy. Frameworks like React let you describe what the UI should look like for the current data and update the page for you.

The jaadu sits calmly at a restaurant table pointing at a menu, while behind a counter a busy cook juggles several pans at once.

Think of it like this

Ordering from the menu versus cooking every step

With plain DOM code you're the cook who must remember every step: chop, heat the pan, add oil, stir, plate. Forget one and dinner is ruined. With React you're the customer who simply says, 'One paneer tikka, please.' You describe what you want for the current data, and React works out the steps to make the page match.

Watch it happen

Updating a cart count

Plain DOM (imperative)

  • Find the badge element
  • Change its text
  • Show or hide the empty message
  • Remember to do this everywhere the cart changes

React (declarative)

  • Keep cart in state
  • Write: <Badge count={cart.length} />
  • Change the state
  • React updates every place that uses it

You still need JavaScript basics, since React is JavaScript. But for apps with lots of changing data, describing the UI beats wiring every update by hand.

The big ideas

What you need to know

Components

You build the UI from small reusable pieces, like ProductCard or Navbar, instead of one giant HTML file.

UI follows data

You change the data (state), and the framework updates the page for you. Less forgotten updates, fewer bugs.

Shared conventions

Teams follow the same patterns, so a new developer can understand the project faster.

A big ecosystem

React has ready-made solutions for routing, forms and data fetching, and many Indian startups use it, so it shows up in lots of job posts.

See it in code

Walk through the code

js
1// Plain JavaScript: you update the DOM yourself2let count = 0;3const badge = document.querySelector("#badge");4document.querySelector("#add").addEventListener("click", () => {5  count = count + 1;6  badge.textContent = count;7  badge.hidden = count === 0;8});9 10// React: you describe the UI for the current state11function Cart() {12  const [count, setCount] = useState(0);13  return (14    <>15      <button onClick={() => setCount(count + 1)}>Add</button>16      {count > 0 && <span className="badge">{count}</span>}17    </>18  );19}

1/4Plain JS: you must remember every place that changes when count changes.

The same feature twice. The React version never touches the DOM directly; it just says what to show for each count.

Save yourself the pain

Common mistakes

Oops

Jumping into React before you're comfortable with JavaScript.

Do this instead

React is JavaScript. Arrays, map, functions, objects and events must feel easy first, or every error will be confusing.

Oops

Thinking a framework is needed for every site.

Do this instead

A simple landing page is fine in plain HTML and CSS. Frameworks pay off when there's lots of changing data.

Your mission

Feel the pain first

~20 min

Quick check

What does it mean that React is 'declarative'?

Go deeper

  1. 1Think about how much code your to-do app would need with ten more features.
  2. 2Read the React docs' Quick Start page once before writing any code.
  3. 3Learn that React, Vue, Angular and Svelte solve the same problem in different ways.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge