Large webpages built with plain JavaScript quickly become messy โ a single file manipulating the DOM directly for a header, a sidebar, a product list, and a footer all at once is hard to maintain and reason about. React's core idea is to split a UI into small, independent components, each responsible for one piece of the interface:
Each box in this tree becomes its own React component โ a self-contained, reusable, testable unit that can be built, understood, and updated in isolation from the rest of the app.
In plain JavaScript, updating the UI usually means manually finding an element with document.querySelector() and mutating it directly โ and as an app grows, keeping track of which piece of code touches which element becomes genuinely difficult. React flips this: you describe what the UI should look like for a given set of data, and React figures out how to update the actual browser DOM efficiently on its own, using a system called the virtual DOM.
// Plain JavaScript: manually find and update the DOM
const heading = document.querySelector("h1");
heading.textContent = "Hello, React!";
// React: just describe what the UI should look like
function App() {
return <h1>Hello, React!</h1>;
}The plain JavaScript version imperatively tells the browser exactly which steps to take. The React version declaratively describes the end result โ React handles the DOM manipulation internally.
All three are popular for building modern UIs, but they differ in scope. React is deliberately just a UI library โ it doesn't ship routing or state management out of the box, so you add tools like React Router as needed, giving you flexibility to assemble your own toolkit. Angular is a complete, opinionated framework that includes routing, forms, and HTTP handling built in. Vue sits in between, offering an approachable core with official companion libraries. React's flexibility and massive ecosystem (especially in job markets) is the main reason it's usually the first choice recommended to beginners.
A common beginner misconception is treating React like a complete framework such as Angular. React deliberately handles only the UI layer โ for routing, form validation, or global state, you'll add separate libraries (covered in later chapters like React Router and Context API). Don't be surprised when a fresh React project has no built-in routing.
Before writing any code, sketch out your own version of the component tree diagram above for a personal portfolio website โ what would the Header, MainContent, and Footer components each contain?
// No code yet โ Chapter 3 covers setup.
// Sketch (in comments) your component tree:
// App
// โโโ Navbar
// โโโ HeroSection
// โโโ ProjectsList
// โโโ ContactFooter
Q What is React used for?
React is used to build interactive user interfaces for websites and mobile apps (via React Native), from small widgets to complete single-page applications like Instagram or Facebook itself, both of which are built with React.
Q Do I need to know JavaScript before learning React?
Yes. React is a JavaScript library, so you write React using JavaScript syntax extended with JSX. Chapter 2 covers exactly which JavaScript concepts you need to be comfortable with first.