What is React and Why It Matters
What is React and Why It Matters
If you've used any AI coding tool to build a web application, the code it generated was almost certainly written in React. Before you can work with that code — or ask AI better questions — you need to understand what React is and why it dominates modern web development.
What is React?
React is a JavaScript library for building user interfaces. Created by Facebook (now Meta) in 2013, it has become the most popular way to build web applications.
At its core, React does one thing well: it lets you build UIs out of reusable components — small, self-contained pieces of interface that you can combine like building blocks.
// A simple React component function WelcomeMessage() { return <h1>Hello, welcome to my app!</h1>; }
That's a complete React component. It's a JavaScript function that returns what looks like HTML (but is actually JSX — more on that below).
The Virtual DOM
One of React's key innovations is the Virtual DOM. Here's the idea:
- The DOM (Document Object Model) is the browser's representation of your web page. Updating it directly is slow.
- React keeps a virtual copy of the DOM in memory. When your data changes, React compares the virtual copy with the real DOM and only updates what actually changed.
Your Data Changes
↓
React updates Virtual DOM
↓
React compares old vs new Virtual DOM (called "diffing")
↓
Only changed elements are updated in the real DOM
This is why React apps feel fast — instead of re-rendering an entire page, React surgically updates just the parts that need to change.
The Component Model
Everything in React is a component. A component is a function that returns UI:
// A button component function LikeButton() { return <button>Like 👍</button>; } // A card component that uses other components function UserCard() { return ( <div className="card"> <h2>Alice Johnson</h2> <p>Software Engineer</p> <LikeButton /> </div> ); } // A page component that uses card components function UserList() { return ( <div> <h1>Team Members</h1> <UserCard /> <UserCard /> <UserCard /> </div> ); }
Notice how components nest inside each other. This is the power of React — you build small pieces, then compose them into larger features, then into full pages.
Why React is the #1 Choice for AI-Generated Apps
When you ask Claude Code, Cursor, or any AI tool to build a web app, React is the default choice. Here's why:
1. Massive Ecosystem
React has more packages, tutorials, and examples than any other framework. AI models have been trained on enormous amounts of React code, so they generate high-quality React output.
2. Component Reusability
AI excels at generating self-contained components. The component model maps perfectly to how AI generates code — one focused piece at a time.
3. Industry Standard
Over 40% of professional developers use React. It's used by Netflix, Airbnb, Discord, Meta, and countless startups. Learning React means learning the industry standard.
4. Next.js Integration
React pairs with Next.js to give you routing, server-side rendering, and API routes out of the box — a complete full-stack framework.
JSX: HTML Inside JavaScript
The most distinctive thing about React is JSX — a syntax that lets you write HTML-like code inside JavaScript:
// This is JSX function Greeting({ name }: { name: string }) { return ( <div className="greeting"> <h1>Hello, {name}!</h1> <p>Welcome to our application.</p> </div> ); }
JSX looks like HTML, but there are a few differences:
| HTML | JSX |
|---|---|
class="..." | className="..." |
for="..." | htmlFor="..." |
onclick="..." | onClick={...} |
| Self-closing optional | Self-closing required: <img /> |
| Strings only | JavaScript expressions: {variable} |
The curly braces { } in JSX let you embed JavaScript expressions — variables, function calls, conditional logic, and more.
function UserGreeting({ user }: { user: { name: string; isAdmin: boolean } }) { return ( <div> <h1>Hello, {user.name}!</h1> {user.isAdmin && <span className="badge">Admin</span>} <p>You have {user.isAdmin ? "full" : "limited"} access.</p> </div> ); }
What to ask your AI: "I see className instead of class in this React code. Can you explain the differences between HTML and JSX?"
Creating Your First Component
Here's a practical component you might ask AI to build:
interface ProductCardProps { name: string; price: number; imageUrl: string; inStock: boolean; } function ProductCard({ name, price, imageUrl, inStock }: ProductCardProps) { return ( <div className="border rounded-lg p-4 shadow-sm"> <img src={imageUrl} alt={name} className="w-full h-48 object-cover rounded" /> <h3 className="text-lg font-bold mt-2">{name}</h3> <p className="text-gray-600">${price.toFixed(2)}</p> {inStock ? ( <span className="text-green-600">In Stock</span> ) : ( <span className="text-red-600">Out of Stock</span> )} </div> ); }
This component receives data through props (properties), which we'll cover in depth in the next tutorial.
Project Setup: Vite vs Next.js
There are two main ways to start a React project:
Option 1: Vite (Client-Side React)
Vite is a fast build tool for React applications:
npm create vite@latest my-app -- --template react-ts cd my-app npm install npm run dev
Best for: Single-page applications, simple projects, learning React.
Option 2: Next.js (Full-Stack React)
Next.js adds server-side rendering, routing, and API routes:
npx create-next-app@latest my-app --typescript --tailwind --app cd my-app npm run dev
Best for: Production apps, SEO-important sites, full-stack projects.
Which should you choose? If you're building anything beyond a simple experiment, go with Next.js. It's what AI tools default to, and it gives you more features out of the box.
What to ask your AI: "Set up a new Next.js project with TypeScript and Tailwind CSS. Show me the folder structure and explain each important file."
Key Takeaways
- React is a library for building UIs with reusable components
- The Virtual DOM makes updates fast by only changing what's necessary
- Components are functions that return JSX (HTML-like syntax in JavaScript)
- Components nest inside each other to build complex UIs from simple pieces
- Next.js extends React with routing, server rendering, and more
- AI tools generate React code because it's the industry standard with the largest ecosystem
What's Next?
Now that you understand what React is, the next tutorial covers the three core concepts you'll use in every component: Components, Props, and State.
What to ask your AI: "I'm new to React. Can you create a simple component that displays a list of items and explain each part?"