Introduction to React
Introduction to React explains React as a declarative, component-based UI library, covering state-driven rendering, component trees, JSX, React DOM, React 19.x, architecture, performance, security, accessibility, and interview preparation.
Learning Objectives
By the end of this lesson, you will be able to:
- Explain what React is in practical and technical terms.
- Understand why React was created.
- Explain the problems React solves in frontend development.
- Understand declarative UI development.
- Understand React's component-based architecture.
- Explain how React applications represent UI as a component tree.
- Understand the relationship between state and UI.
- Understand React's rendering model at a high level.
- Understand the role of JSX.
- Understand React and the browser DOM.
- Distinguish React from React DOM and React frameworks.
- Understand React's evolution from its early architecture to modern React.
- Understand where React fits in an enterprise application.
- Identify common misconceptions about React.
- Explain React confidently in technical interviews.
Introduction
Let's begin with a practical problem.
Suppose TechLearningPro starts as a simple website.
You have:
HomeCoursesTutorialsBlogAboutContact
Initially, plain HTML and CSS are enough.
Then the application grows.
Now you need:
- login
- registration
- course search
- filters
- user profiles
- course progress
- shopping cart
- payments
- notifications
- dashboards
- personalized recommendations
- real-time updates
Suddenly, the frontend is no longer just a collection of pages.
It becomes an application.
And applications have state.
For example:
User│├── Logged in?├── Name├── Role└── PermissionsCourse│├── Title├── Price├── Progress└── Completion status
Now imagine that one state change affects several parts of the screen.
A user completes a lesson:
Lesson Completed│├── Progress bar changes├── Course status changes├── Dashboard changes├── Certificate becomes available└── Notification appears
The central frontend engineering problem becomes:
How do we keep the user interface synchronized with changing application state without turning the application into a collection of difficult-to-maintain DOM manipulation code?
React was created to address this class of problems.
What Is React?
React is a JavaScript library for building user interfaces from reusable components.
That definition is accurate, but for an engineer, it isn't enough.
A better mental model is:
React provides a declarative programming model for describing user interfaces as a function of application state.
Conceptually:
UI = f(State)
For example:
function CourseStatus({ completed }: { completed: boolean }) {return completed? <span>Completed</span>: <span>In Progress</span>;}
The component doesn't manually tell the browser:
Find element↓Change text↓Change CSS↓Update icon
Instead, it describes:
If completed↓Show "Completed"Otherwise↓Show "In Progress"
React handles the rendering process.
This is one of the most important ideas in React.
Why Was React Created?
To understand React properly, don't start with:
React has JSX and hooks.
Start with:
What problem was React trying to solve?
Modern web applications became increasingly interactive.
A page could contain:
NavigationSearchFormsTablesNotificationsDialogsChartsMenusUser profilesReal-time information
And all of these could depend on changing data.
Traditional JavaScript could certainly build these applications.
The problem wasn't:
JavaScript cannot build complex UIs.
It can.
The problem was managing complexity.
Consider an application with:
10 components50 interactions100 pieces of UI state20 API operations
Manually maintaining relationships between data and DOM elements becomes increasingly difficult.
React introduced a different model:
Application State│▼React Components│▼UI
When state changes:
State Change│▼React Render│▼Determine UI Changes│▼Commit Changes│▼Browser
This provides a much more structured way of thinking about UI.
Imperative vs Declarative UI
This distinction is fundamental.
Imperative Programming
Imperative code tells the system how to perform an operation.
For example:
const button = document.querySelector("#login");button.textContent = "Logout";button.classList.add("logged-in");
You're explicitly instructing the browser what to change.
The mental model is:
Find element↓Modify element↓Modify another element↓Modify another element
Declarative Programming
React encourages a declarative model.
You describe the desired result:
function LoginButton({ loggedIn }: { loggedIn: boolean }) {return (<button>{loggedIn ? "Logout" : "Login"}</button>);}
The logic is essentially:
loggedIn = true↓LogoutloggedIn = false↓Login
The component describes the UI.
React manages the rendering process.
This doesn't mean React magically eliminates all complexity.
It means the complexity is organized around a different abstraction.
The Component Model
The second major idea behind React is components.
A component represents a reusable part of the user interface.
For example:
function Header() {return (<header><h1>TechLearningPro</h1></header>);}
Another:
function CourseCard() {return (<article><h2>React Mastery</h2><p>Advanced React course</p></article>);}
Then:
function HomePage() {return (<><Header /><CourseCard /><CourseCard /></>);}
The UI becomes composable.
Component Composition
Components can contain other components.
Consider:
Application│▼HomePage│┌───┼──────────────┐▼ ▼ ▼Header Hero CourseList│┌────┼────┐▼ ▼ ▼Course Course CourseCard Card Card
This is composition.
Instead of creating one enormous UI structure, we create smaller building blocks.
This provides:
- reuse
- separation of concerns
- easier testing
- easier maintenance
- clearer ownership
- better team collaboration
React as a Component Tree
A React application can be visualized as a tree.
For TechLearningPro:
App│├── Header│ ├── Logo│ ├── Navigation│ └── UserMenu│├── MainContent│ ├── Hero│ ├── CourseSearch│ └── CourseList│ ├── CourseCard│ ├── CourseCard│ └── CourseCard│└── Footer
This tree isn't just a visual representation.
It becomes important for understanding:
- data flow
- state ownership
- rendering
- performance
- context
- debugging
- component architecture
The React Data Flow
React applications traditionally emphasize one-way data flow.
Consider:
Parent││ props▼Child
For example:
function CourseCard({title}: {title: string;}) {return <h2>{title}</h2>;}
The parent provides:
<CourseCard title="React Mastery" />
So:
Parent││ title▼CourseCard│▼UI
This makes data relationships easier to reason about.
State and UI
Now introduce state.
Imagine a course page.
The user clicks:
[ Mark Complete ]
The state changes:
completed = false│▼User clicks button│▼completed = true│▼React renders│▼UI reflects new state
The component could conceptually be:
function LessonStatus() {const [completed, setCompleted] = useState(false);return (<button onClick={() => setCompleted(true)}>{completed ? "Completed" : "Mark Complete"}</button>);}
Notice what we are not doing.
We aren't manually searching the DOM and changing the button text.
We change state.
The UI follows the state.
That is the React mental model.
React Rendering
A simplified React rendering flow is:
Initial Application│▼React Root│▼Component Tree│▼Render│▼Commit│▼Browser DOM
Later, when something changes:
User Interaction│▼State Update│▼React Schedules Work│▼Render│▼Reconciliation│▼Commit│▼DOM
The important point is:
Rendering and DOM mutation are not the same thing.
A React component can render without every DOM element being recreated.
This distinction becomes critical when studying performance.
What Is JSX?
React code frequently looks like:
function Welcome() {return <h1>Welcome to TechLearningPro</h1>;}
The HTML-like syntax is called JSX.
JSX makes it easier to describe UI structures alongside JavaScript logic.
For example:
function CourseCard() {const title = "React Mastery";return (<article><h2>{title}</h2><button>Start Learning</button></article>);}
JSX is not HTML.
It is syntax that is transformed into JavaScript representation that React can use.
We'll explore JSX deeply in a dedicated lesson.
React and the Browser DOM
The browser fundamentally works with the DOM.
React provides an abstraction for describing UI.
A simplified architecture is:
React Components│▼React Rendering System│▼React DOM│▼Browser DOM│▼Screen
This is why the distinction between:
React
and:
React DOM
matters.
React itself provides the core component and rendering model.
React DOM provides the browser DOM integration.
React Is Not the Browser
This sounds obvious, but it matters architecturally.
React does not replace:
- HTML
- CSS
- JavaScript
- browser APIs
- HTTP
- browser storage
- accessibility standards
Instead:
Browser Platform│├── HTML├── CSS├── JavaScript├── DOM└── Web APIs│▼React
React works with the web platform.
A strong React developer should understand the browser itself.
React Ecosystem
React is not an isolated technology.
A production application might use:
React│├── React DOM│├── React Router│├── TanStack Query│├── Redux Toolkit│├── React Hook Form│├── Zod│├── Testing Library│├── Vitest│├── Playwright│└── Next.js
But these technologies do different jobs.
For example:
| Technology | Primary Responsibility |
|---|---|
| React | UI/component model |
| React DOM | Browser DOM integration |
| React Router | Routing |
| TanStack Query | Server-state management |
| Redux Toolkit | Client-state management |
| React Hook Form | Form management |
| Zod | Schema validation |
| Playwright | End-to-end testing |
| Next.js | React framework |
A common beginner mistake is to treat the entire ecosystem as "React."
It isn't.
React vs Next.js
This distinction is especially important.
React
Provides the UI programming model.
ComponentsHooksStateRendering
Next.js
Provides a broader application framework around React.
Depending on the version and configuration, it can provide:
RoutingServer renderingStatic generationServer componentsServer-side capabilitiesCachingDeployment-oriented features
Therefore:
React│├── Can be used directly│└── Can be used inside frameworks│└── Next.js
You should never say:
React is Next.js.
A better interview answer is:
React is the UI library, while Next.js is a framework built around React that provides additional application-level capabilities.
React's Evolution
React was introduced publicly by Facebook in 2013.
Its evolution can be broadly understood as:
Early React│▼Component-based UI│▼JSX│▼Virtual DOM / reconciliation model│▼Hooks│▼Concurrent rendering capabilities│▼React 18│▼React 19│▼Modern React 19.x
This evolution matters because many tutorials still teach older React patterns.
For example, older React applications frequently use:
Class ComponentsLifecycle MethodsCreate React App
Modern React development generally emphasizes:
Functional ComponentsHooksModern toolingFramework-based development where appropriate
The official React documentation currently lists React 19.2 as the latest stable React release.
React 19 and Modern React
Modern React goes beyond the traditional explanation:
React = components + Virtual DOM.
React 19 introduced a number of improvements around actions, forms, and asynchronous UI workflows.
For example, modern React provides APIs such as:
useActionStateuseFormStatususeOptimistic
These are particularly useful when working with modern form and asynchronous interaction patterns.
React 19.2 further introduced capabilities including:
<Activity />useEffectEventcacheSignalPartial Pre-renderingPerformance tracks
These features demonstrate an important point:
React continues to evolve beyond its original client-side rendering model.
However, version-specific features should always be checked against the React version used by the application.
React Is Declarative, Not Magical
One misconception is:
React automatically handles everything.
It doesn't.
You still have to make architectural decisions.
For example:
Where should state live?│▼Which API should provide data?│▼How should authentication work?│▼How should permissions work?│▼How should errors be handled?│▼How should the application be tested?
React gives you powerful primitives.
It doesn't automatically create a good architecture.
Real-World TechLearningPro Architecture
Let's imagine TechLearningPro as a production React platform.
Browser│▼React Application│┌──────────────┼──────────────┐│ │ │▼ ▼ ▼Courses Learning Profile│ │ │└──────────────┼──────────────┘▼ApplicationLogic│┌─────────────┴─────────────┐▼ ▼Client State Server State│ │└─────────────┬─────────────┘▼API Layer│▼API Gateway│┌───────────────┼────────────────┐▼ ▼ ▼Course Service User Service Payment Service
Here React is responsible primarily for the user interface and client-side interaction model.
The backend remains responsible for:
- business rules
- authorization
- data persistence
- payment processing
- domain logic
This separation is fundamental to good architecture.
React in Enterprise Development
At enterprise scale, React becomes more than writing components.
You need to consider:
Architecture
Feature boundariesDependency boundariesShared librariesDesign systems
Performance
Bundle sizeRenderingNetwork requestsLarge listsCaching
Security
AuthenticationAuthorizationXSSCSRFCSPToken handling
Quality
Unit testsIntegration testsE2E testsAccessibilityCode reviewStatic analysis
Operations
LoggingMonitoringError trackingDeploymentCI/CDFeature flags
Therefore, learning React professionally means learning the ecosystem around the component model.
Performance Perspective
A beginner often thinks:
React is fast.
That isn't a sufficient engineering statement.
React can enable efficient UI updates, but poorly designed React applications can still be slow.
For example:
Large component tree+Poor state placement+Huge JavaScript bundle+Large API payload+Expensive calculations+Large unvirtualized list
can produce a slow application.
Performance engineering should follow:
Measure↓Identify bottleneck↓Understand cause↓Optimize↓Measure again
Not:
Problem↓Add useMemo()
That distinction will become important later.
Security Perspective
React doesn't eliminate security risks.
For example:
{isAdmin && <DeleteButton />}
is useful for controlling what appears in the UI.
But it is not authorization.
A malicious user could call:
DELETE /api/users/123
directly.
Therefore:
Frontend permission check≠Backend authorization
The backend must enforce authorization.
Similarly, developers must understand:
- XSS
- secure authentication
- token handling
- cookies
- CORS
- CSRF
- CSP
- dependency vulnerabilities
These topics will be covered later in the course.
Accessibility Perspective
A professional React component should also be accessible.
Prefer:
<button onClick={save}>Save</button>
over:
<div onClick={save}>Save</div>
The semantic button provides better browser behavior and accessibility support.
Important areas include:
Semantic HTML↓Keyboard navigation↓Focus management↓Labels↓ARIA where appropriate↓Screen readers
Accessibility should be considered during component design, not added after development is complete.
Common Misconceptions
Misconception 1: React is a programming language
No.
React is a JavaScript library.
Misconception 2: React replaces JavaScript
No.
React is built using JavaScript and relies heavily on JavaScript concepts.
You need strong JavaScript fundamentals.
Misconception 3: React is only the Virtual DOM
No.
The rendering architecture is broader than that.
Misconception 4: React automatically makes applications fast
No.
Poor architecture can still produce poor performance.
Misconception 5: React automatically secures applications
No.
Security requires frontend and backend controls.
Misconception 6: Every application needs Redux
No.
State requirements should determine the architecture.
Misconception 7: Every value belongs in state
No.
Derived values should generally be calculated rather than unnecessarily duplicated.
Misconception 8: useEffect() is the React equivalent of "run this code"
Not exactly.
Effects are primarily for synchronizing React with external systems.
This will be discussed in depth when we reach useEffect.
Misconception 9: React and Next.js are the same
No.
Next.js is a framework built around React.
Misconception 10: More abstractions mean better architecture
Not necessarily.
Good architecture is about appropriate boundaries, not maximum abstraction.
Best Practices
For modern React development:
- Learn JavaScript deeply before relying on React abstractions.
- Understand the component model.
- Prefer functional components.
- Keep components focused.
- Use meaningful component boundaries.
- Keep state close to where it is needed.
- Avoid unnecessary global state.
- Separate client state from server state.
- Avoid unnecessary effects.
- Use TypeScript for large production applications.
- Use semantic HTML.
- Build accessibility into components.
- Measure before optimizing.
- Avoid unnecessary memoization.
- Keep API communication separate from presentation when appropriate.
- Organize large applications around features/domains.
- Understand the browser platform.
- Keep React and ecosystem dependencies current.
- Understand which features belong to React and which belong to frameworks/libraries.
- Never treat frontend UI restrictions as backend authorization.
A Simple React Mental Model
If you remember only one diagram from this lesson, remember this:
APPLICATION STATE│▼REACT COMPONENTS│▼UI DESCRIPTION│▼REACT RENDERING│▼DOM COMMIT│▼BROWSER│▼USER INTERACTION│▼STATE UPDATE│└──────────────►
This cycle is at the heart of React application development.
Practical Exercise
Build a Simple Course Introduction
Create a React component representing a TechLearningPro course.
Requirements
Create:
CourseIntroduction│├── Course Title├── Description├── Instructor├── Difficulty├── Duration└── Start Learning Button
Example:
function CourseIntroduction() {return (<section><h1>React Mastery</h1><p>Learn React from fundamentalsto enterprise architecture.</p><p>Level: Advanced</p><p>Duration: 40 hours</p><button>Start Learning</button></section>);}
Challenge
Now break it into:
CourseIntroduction│├── CourseHeader├── CourseMetadata└── StartLearningButton
Then ask yourself:
Which component should own which responsibility?
That question will become increasingly important throughout this course.
Interview questions & answers
Interview preparation
15 questions grouped by difficulty — expand any card for a model answer and follow-up probe.
Beginner
1What is React?
BeginnerModel answer
React is a JavaScript library for building user interfaces using reusable components.
Its main strength is its declarative programming model, where we describe what the UI should look like based on application state.
2Why was React created?
BeginnerModel answer
The main problem was managing complexity in interactive user interfaces.
As applications became more dynamic, manually keeping the DOM synchronized with application state became difficult.
React introduced a component-based and declarative approach that makes those relationships easier to reason about.
3What is a component?
BeginnerModel answer
A component is an independent, reusable piece of UI.
In modern React, components are typically functions that return JSX and can receive data through props and manage state using hooks.
4What is JSX?
BeginnerModel answer
JSX is a syntax extension that allows us to describe UI using HTML-like syntax inside JavaScript or TypeScript.
It makes component code easier to read, but JSX itself is not HTML.
Intermediate
5What does declarative UI mean?
IntermediateModel answer
It means I describe the desired UI for a particular state rather than manually manipulating the DOM to produce that UI.
React takes responsibility for determining and committing the necessary updates.
6What happens when state changes?
IntermediateModel answer
A state update schedules React to perform rendering work.
React calls the relevant component functions to determine the new UI representation, reconciles the result, and commits the required changes to the host environment.
7Why is component composition important?
IntermediateModel answer
Composition allows us to build complex interfaces from smaller units.
It improves maintainability, reuse, testing, and team ownership.
But I wouldn't blindly create components for every line of UI; the boundaries should represent meaningful responsibilities.
8Is React a framework?
IntermediateModel answer
React itself is generally described as a UI library.
js provides broader application capabilities around React.
Advanced
9Why is one-way data flow useful?
AdvancedModel answer
It makes data relationships easier to reason about.
When data generally flows from parent to child through props, I can trace where information originates and how it reaches the UI.
For complex applications, that predictability becomes valuable when debugging and designing state boundaries.
10Does React eliminate DOM manipulation?
AdvancedModel answer
It largely allows application code to avoid directly managing ordinary UI DOM updates.
React manages the rendering process.
However, direct DOM interaction still has legitimate use cases through mechanisms such as refs—for example, focusing an input or integrating with a third-party DOM library.
11Does React guarantee good performance?
AdvancedModel answer
No.
React provides a rendering model designed to efficiently update UI, but application architecture still determines performance.
Poor state placement, unnecessary rendering, large bundles, expensive computations, and inefficient network usage can make a React application slow.
12What problem does React actually solve?
AdvancedModel answer
I'd say React primarily solves the problem of managing complex, interactive UI in a predictable way.
It gives us a declarative component model where UI can be described as a function of state.
It doesn't solve backend architecture, database design, authentication, or every frontend architectural concern.
13How would you explain React to a non-technical stakeholder?
AdvancedModel answer
I'd say React is a way of building a large application interface from smaller reusable pieces.
When something changes—for example, a user completes a course—the application updates the relevant parts of the screen based on the new information instead of developers manually coordinating every visual change.
14What would you consider before choosing React for an enterprise application?
AdvancedModel answer
I'd look beyond the library itself.
I'd evaluate application complexity, team expertise, accessibility requirements, performance requirements, SEO needs, routing, server rendering, ecosystem maturity, testing strategy, deployment model, and long-term maintainability.
React is powerful, but the surrounding architecture matters just as much.
15How would you prevent React architecture from becoming overly complex?
AdvancedModel answer
I'd establish clear boundaries and resist premature abstraction.
I'd keep state local where possible, separate server state from client state, establish feature ownership, and introduce shared abstractions only when multiple features genuinely need the same stable behavior.
Final Understanding
After this lesson, you should no longer think of React simply as:
React = JSX + Components
Instead, think:
React│├── Declarative UI│├── Component Model│├── Composition│├── State-driven Rendering│├── Rendering/Reconciliation│└── Ecosystem Integration
And around React:
React│┌───────────┼───────────┐▼ ▼ ▼Routing State Data│ │ │▼ ▼ ▼React Router Redux/ TanStackContext Query│ │ │└───────────┼───────────┘▼ApplicationArchitecture
The deeper lesson is this:
React is not valuable simply because it provides components. React is valuable because it provides a predictable way to model complex, state-driven user interfaces.
Once this mental model is clear, the rest of React becomes much easier to understand.
Next Lesson
**React vs Traditional Web Development**
The next lesson should answer an important engineering question:
Why do we need React when JavaScript, HTML, CSS, and the browser DOM already exist?
We will compare:
Traditional Web Development│▼Manual DOM Manipulation│▼Increasing UI Complexity│▼Component-Based Development│▼React
and build a clear understanding of exactly where React provides value—and where plain JavaScript may still be the better choice.