Mastering React: A Comprehensive Guide from Basics to Proficiency
A systematic approach to mastering React's core concepts and practical techniques, guided by the Feynman Technique, Simon Learning Method, SQ3R Reading Method, and Cornell Note-Taking System.
2026-06-01Technology, React
1. Overview & Questions (SQ3R: Survey & Question)
SQ3R Step 1: Survey the big picture and formulate key questions.
What is React?
React is an open-source JavaScript UI library developed by Meta (formerly Facebook) for building web and native user interfaces. Since its release in 2013, React has become one of the most widely adopted frontend libraries in the world. Its core philosophy is to break the UI into independent, reusable pieces called Components, each managing its own logic and appearance.
The current latest version is React 19.2, which introduces major features including Server Components, the React Compiler, and the use API. React is not a full-featured framework — it focuses on the view layer and works with complementary libraries for routing, state management, and more.
Core problems React solves:
Managing UI complexity: Decomposing complex interfaces into maintainable, composable units through componentization
Keeping state and views in sync: Through declarative programming, developers describe what the UI should look like, and React efficiently updates the DOM
Cross-platform development: The same component model works for web (React DOM) and mobile (React Native)
Key Questions
When should you use React? — Single-page applications, interaction-heavy web apps, products requiring cross-platform support
What advantages does React have over alternatives? — Mature ecosystem, massive community, flexible composition, sustained investment from Meta
What prerequisites are needed? — HTML, CSS, JavaScript (ES6+), basic DOM knowledge
Technology Landscape
React's architecture can be summarized as the collaboration of these core modules:
React Application
├── Describing the UI
│ ├── Components — The fundamental building blocks of UI
│ ├── JSX — Declarative markup syntax
│ ├── Props — Data passing between components
│ └── Conditional & List Rendering
├── Adding Interactivity
│ ├── Events — Event handling
│ ├── State — A component's memory
│ └── Render & Commit
├── Managing State
│ ├── Lifting State Up
│ ├── Reducer — Complex state logic
│ ├── Context — Deep data passing
│ └── Reducer + Context pattern
└── Escape Hatches
├── Refs — Referencing DOM nodes and values
├── Effects — Synchronizing with external systems
└── Custom Hooks — Logic reuse
2. Explained in Plain Language (Feynman Technique)
Feynman Technique core idea: If you can't explain something in simple language, you don't truly understand it.
Core Concepts
Components
A component is a JavaScript function that returns the markup you want to display. A component can be as small as a button or as large as an entire page.
function MyButton() { return <button>I'm a button</button>;}// Using a component inside another componentexport default function MyApp() { return ( <div> <h1>Welcome to my app</h1> <MyButton /> </div> );}
Important: Component names must start with a capital letter (MyButton), while HTML tags use lowercase (button).
JSX
JSX is a syntax for writing HTML-like markup inside JavaScript. It is stricter than HTML: tags must be self-closing (like <br />), and a component cannot return multiple root tags — you need to wrap them in a <div> or an empty <>...</> fragment.
function AboutPage() { return ( <> <h1>About</h1> <p> Hello there. <br /> How do you do? </p> </> );}
Use curly braces {} to embed JavaScript expressions inside JSX:
const user = { name: "Hedy Lamarr" };return <h1>{user.name}</h1>;
Props
Props are data passed from a parent component to a child component — like function arguments.
useState returns two things: the current state value (count) and a setter function (setCount). Every time you call setCount, React re-renders the component.
Event Handling
Event handlers are defined inside components and attached via onEventName attributes.
function MyButton() { function handleClick() { alert("You clicked me!"); } return <button onClick={handleClick}>Click me</button>;}
Notice: onClick={handleClick} has no parentheses at the end. You pass the function itself, not the result of calling it. React will call it when the user clicks.
Conditional Rendering
React has no special syntax for conditions. Use plain JavaScript:
The key helps React identify which items have changed (inserted, deleted, or reordered).
Analogies
Components = LEGO bricks: Each brick has its own shape and function. You can freely combine them into larger creations. A button is one brick; a page is many bricks assembled together.
Props = Delivery packages: A parent component "ships packages" to child components via props. The child receives and uses the contents but cannot modify the package itself.
State = A component's notebook: Each component has its own little notebook to record information that changes. When the notebook content changes, the UI updates automatically.
JSX = HTML's supercharged sibling: It is like writing HTML where you can embed JavaScript expressions directly using curly braces {}.
Hooks = Plug-in interfaces: Hooks are like USB ports that let you "plug in" various React capabilities (state management, side effects, references) into your components.
Context = Indoor broadcast: If Props are a delivery person passing packages floor by floor, Context is like a room broadcast — a top-level component broadcasts a message, and any component at any nesting level can hear it.
Common Misconceptions
"React is an MVC framework" — No. React is just the V (view layer). Routing, data fetching, and other concerns require additional libraries.
"JSX is just HTML" — No. JSX is a JavaScript syntax extension that is stricter (tags must be closed, use className instead of class).
"State changes immediately update the DOM" — No. React batches state updates and applies them at the right time.
"Every render rebuilds the entire DOM" — No. React uses the Virtual DOM diff algorithm to update only what actually changed.
"Hooks can be called inside if/for" — No. Hooks must be called at the top level of a component, never inside conditions, loops, or nested functions.
"useEffect is just like Vue's watch" — Not quite. useEffect runs after the render is committed to the screen and is meant for synchronizing with external systems, not simply watching data changes.
"Context can replace all state management" — No. Context is great for "long-distance" data passing, but overuse causes unnecessary re-renders.
3. Cone of Depth (Simon Learning Method)
Simon Learning Method: Focused effort, goal-oriented, cone-shaped depth — start from the core and expand outward.
Layer 1: Core Fundamentals
1. useState — Managing State
useState is the most fundamental Hook, giving components "memory."
Data fetching -> Set an ignore flag to discard stale responses
Animations -> Reset to initial values
Timers -> setTimeout / clearTimeout
Layer 3: Deep Dive
1. Render Mechanism: Render & Commit
React updates the UI in three steps:
Trigger: A setState call or the initial render
Render: React calls your component function to compute new JSX (Virtual DOM)
Commit: React applies the changes to the real DOM
State is a snapshot: Each render has its own fixed state values. Event handlers and Effects capture state values from that specific render.
function Counter() { const [count, setCount] = useState(0); function handleAlertClick() { setTimeout(() => { alert("You clicked on: " + count); // Shows the count at click time, not current }, 3000); } return ( <div> <p>{count}</p> <button onClick={() => setCount(count + 1)}>+1</button> <button onClick={handleAlertClick}>Show alert</button> </div> );}
2. Batched State Updates & Queuing
React batches state updates. Multiple setState calls in the same event handler trigger only one re-render.
function handleClick() { setCount(count + 1); // count is still the old value here setCount(count + 1); // Still based on old value, only +1}// Correct: Use functional updatesfunction handleClick() { setCount((c) => c + 1); // c is the latest pending value setCount((c) => c + 1); // Based on previous update, result is +2}
3. React Compiler
React 19 introduces the React Compiler, a build-time optimization tool that automatically memoizes components and values:
Automatically identifies where computations should be cached
Reduces the need for manual useMemo and useCallback
Can be adopted incrementally, compatible with existing code
Integrated via @babel/plugin-transform-react-compiler
4. The use API
The use API, new in React 19, reads Promises and Context during rendering:
import { use, Suspense } from "react";function Message({ messagePromise }) { const messageContent = use(messagePromise); return <p>Here is the message: {messageContent}</p>;}export function MessageContainer({ messagePromise }) { return ( <Suspense fallback={<p>Downloading message...</p>}> <Message messagePromise={messagePromise} /> </Suspense> );}
5. Thinking in React — The React Mindset
Five steps to building a React application:
Break the UI into a component hierarchy: Divide based on data model and design mockups
Build a static version: Create the UI with props only, no interactivity yet
Find the minimal state: Follow the DRY principle — identify the smallest set of changing data
Identify where state lives: Place state in the closest common parent of the components that use it
Add inverse data flow: Child components update parent state via callback functions
6. Reducer + Context Pattern
This is the pattern for managing complex application state in React:
const val = useSyncExternalStore(subscribe, getSnapshot)
useEffectEvent
Effect event handler (excluded from deps)
const onMsg = useEffectEvent(handler)
Section Summary
React's core philosophy is componentization and declarative UI. Components receive data through Props, manage internal state with State, and pass data deeply via Context. Hooks (useState, useEffect, useRef, etc.) are the sole entry points for components to access React's capabilities. Effects synchronize with external systems, while Custom Hooks enable reuse of stateful logic. React 19's Compiler and use API represent the framework's direction — less boilerplate, more automated optimization.
5. Review & Practice (SQ3R: Recite & Review)
SQ3R final two steps: Recite key points and solidify understanding through practice.
Key Takeaways
React components are JavaScript functions that return JSX; component names must start with a capital letter
Use curly braces {} to embed JavaScript expressions inside JSX
Props are a read-only data flow from parent to child; State is mutable data internal to a component
useState returns [value, setter]; calling the setter triggers a re-render
Lifting State Up is the standard pattern for sharing state between components
List rendering requires a unique key prop on each item
useEffect synchronizes with external systems; always specify a dependency array
Effects need cleanup functions to prevent resource leaks (subscriptions, connections, timers)
Context solves prop drilling but should not replace all state passing
Custom Hooks start with use and share stateful logic between components
useReducer suits complex state logic; combined with Context it forms a global state management solution
State is a fixed snapshot per render; closures capture values from that specific render
Three Rules of React: component purity, React controls invocation, Hook rules
Hands-On Exercises
Static Personal Card Page: Create a component with an avatar, name, and bio. Practice component creation, Props passing, and JSX basics.
Searchable Product List: Follow the "Thinking in React" tutorial to build a product table with search filtering and stock-only toggle. Practice lifting state, conditional rendering, and list rendering.
Chat Room Application: Build a chat component that connects to a mock server. Practice useEffect declaration, dependency arrays, and cleanup functions.
Theme Switching System: Use Context to implement light/dark theme toggling where all nested components automatically adapt. Practice createContext, useContext, and Providers.
Task Management System: Build a Todo app with the Reducer + Context pattern, supporting add, delete, and mark-as-complete. Practice useReducer, Custom Hooks, and Context composition.
Common Pitfalls
Forgetting the dependency array: useEffect without a dependency array runs after every render, potentially causing infinite loops
Using Effects for the wrong things: Actions like purchasing products or submitting forms should be in event handlers, not Effects
Using array index as key: When lists can be reordered, inserted, or deleted, using indices as keys causes rendering bugs. Use stable unique IDs instead
Overusing Context: When a Context value changes, all consumers re-render. For frequently changing data, consider a state management library or scoping state more narrowly