React from Scratch #1: Not a Library, a Mindset
Have you ever opened a React project and thought, “Why does this look so complicated?”
You see things like useState, JSX, components, and hooks, and it feels like learning an entirely new language.
But here’s the reality:
React is not magic. React is just JavaScript — with a better way to think about building user interfaces.
This article starts a new series called “React from Scratch”, where we’ll go step by step from the fundamentals to more advanced concepts.
Today we’ll build the mental model that makes React easier to understand.
The Big Idea: React Is a Way of Thinking
Before React and other modern frameworks became popular, most websites worked in a simple way.
This is called a Multi-Page Application (MPA).
Each user interaction usually triggers a full page reload.
That model worked well for traditional websites, but it doesn’t feel smooth for modern applications like:
When you click around these apps, the page does not fully reload. The interface updates instantly.
This leads us to an important concept.
What Is a Single Page Application (SPA)?
A Single Page Application (SPA) loads one HTML page and updates parts of that page dynamically using JavaScript.
Instead of refreshing the entire page, the application only updates the sections that change.
Traditional websites (MPA):
Modern applications (SPA):
This approach makes applications feel faster, smoother, and more interactive.
However, managing all those updates manually with JavaScript can quickly become complicated.
That’s where React becomes extremely useful.
The Problem React Solves
Imagine you are building a shopping cart interface.
When a user adds an item, several parts of the page need to update:
With plain JavaScript, you might write something like this:
document.querySelector("#cart-count").innerText = newCount;
document.querySelector("#total").innerText = total;
This works for small projects. But as an application grows, manually updating the DOM in many places becomes difficult to maintain.
React introduces a different idea:
Instead of manually updating the UI, you describe what the UI should look like based on the current data.
React then handles the updates automatically.
Understanding the Virtual DOM
To understand why React is fast, we need to talk about the DOM.
The DOM (Document Object Model) is the browser’s internal representation of your HTML. Updating the DOM directly is relatively slow because the browser has to recalculate layout and repaint elements.
React improves performance by introducing something called the Virtual DOM.
Recommended by LinkedIn
A helpful way to think about it is using a draft vs. final document analogy.
Imagine you are editing an important report.
You wouldn’t print a new final copy every time you change a sentence. Instead, you would:
React works in a very similar way.
How the Virtual DOM works:
This process allows React to update the interface efficiently and predictably.
React Applications Are Built with Components
Another key concept in React is components.
A component is simply a reusable piece of the user interface.
For example, a typical application might include components such as:
Instead of writing one large block of UI code, React encourages you to break the interface into small, manageable pieces.
These components can then be reused throughout the application.
Two Types of React Components
Historically, React supported two different ways to create components.
1. Class Components
Earlier versions of React used JavaScript classes.
class Welcome extends React.Component {
render() {
return <h1>Hello World</h1>;
}
}
Here is what happens in this code:
While class components still work, they introduce additional complexity.
2. Functional Components
Today, most modern React applications use functional components.
function Welcome() {
return <h1>Hello World</h1>;
}
Line by line:
Functional components are simpler, cleaner, and easier to maintain, which is why modern React development focuses on them.
Throughout this series, we will focus entirely on functional components.
Key Takeaways
If you remember just a few things from this article, remember these ideas:
Understanding these core ideas will make the rest of React much easier to learn.
Let’s Continue the Conversation
If you are currently learning React, what part has been the most confusing for you so far?
Share your thoughts in the comments. Your questions may help shape the next articles in this React from Scratch series.
Next in the series 👉: React from Scratch #2 Your First React App (What Actually Happens Behind the Scenes)
If you're currently learning React, I'm curious: Which concept felt the hardest to understand at the beginning? • Virtual DOM • State & re-rendering • Thinking in components Or something else entirely? Your answer might help guide the next articles in this React from Scratch series.