Getting Started Lesson 1 of 13
Introduction to React
What React is, why developers use components and state instead of changing the DOM by hand, and your first live React component.
In the JavaScript course, you changed the page by finding elements and updating them: getElementById, textContent, appendChild. That works for small pages, but in big apps it becomes hard to keep the page in sync with your data. React solves this with a simple idea: describe what the page should look like for the current data, and React updates the page for you.
Your first React app
<div id="root"></div>
<script src="/vendor/react.min.js"></script>
<script src="/vendor/react-dom.min.js"></script>
<script src="/vendor/babel.min.js"></script>
<script type="text/babel">
const { useState } = React;
function Counter() {
const [count, setCount] = useState(0);
return (
<div style={{ fontFamily: "sans-serif", padding: 16 }}>
<h2>Likes: {count}</h2>
<button onClick={() => setCount(count + 1)}>👍 Like</button>
</div>
);
}
ReactDOM.createRoot(document.getElementById("root")).render(<Counter />);
</script>
Click the button. Notice what's missing: there's no getElementById("count"), no textContent = .... We just change the data (setCount), and React redraws the parts of the page that depend on it.
The three big ideas
- Components: the UI is built from small, reusable functions like
Counter,NavbarorProductCard. - JSX: you write HTML-like code inside JavaScript to describe what each component shows.
- State: data that can change (like
count). When state changes, React re-renders the component.
Declarative vs imperative
| Plain JavaScript (imperative) | React (declarative) |
|---|---|
| "Find the span, then change its text to 5" | "The heading shows the count" |
| You update every affected element yourself | You update the data; React updates the page |
| Easy to forget one spot | The UI always matches the data |
Where is React used?
- Web apps: Facebook, Instagram, Netflix, Airbnb, Discord.
- Mobile apps with React Native, using the same ideas.
- Frameworks like Next.js build full websites on top of React.
How the examples in this course work
Each example loads three files: React, ReactDOM (which draws React components into the page), and Babel, which translates JSX into normal JavaScript inside the browser. That makes the examples work instantly in the Try-it editor. Real projects translate JSX ahead of time with a build tool, which Lesson 2 explains.
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04