Skip to content

Chapter 1 of 6

React Fundamentals

React is a JavaScript library developed by Facebook for building user interfaces. At its core, React is component-based: an application is composed of small, reusable pieces of UI that each manage their own structure and behavior. Underneath this model sits React's most distinctive performance feature: the virtual DOM. The virtual DOM is a lightweight in-memory representation of the real DOM. When a component's state changes, React builds a new virtual tree, diffs it against the previous one, and applies only the minimal set of changes to the real DOM. This diffing process is called reconciliation.

Reconciliation is not a generic tree diff. React relies on heuristics to keep it fast and predictable: it compares elements by type, and when children are lists, it uses key props to match old elements with new ones. These heuristics let React decide the minimum number of DOM operations needed to reflect the latest state, which is what makes React efficient even for large, interactive applications.

To make components ergonomic to write, React extends JavaScript with JSX, a syntax that lets you write HTML-like markup directly inside JavaScript files. Browsers cannot run JSX as-is; tools like Babel transpile JSX into React.createElement() calls before the code reaches the browser. Because JSX is just JavaScript, you can freely embed expressions, call functions, and pass values as attributes — a flexibility that vanilla templates do not offer.

All chapters
  1. 1React Fundamentals
  2. 2Components, Props, and State
  3. 3The Hooks API
  4. 4Context, Lifting State, and Composition
  5. 5Advanced Rendering and Errors
  6. 6Lists, Events, and Performance

Drill it

Reading is not remembering. These come from the React Framework deck:

Q

What is React?

React is a JavaScript library developed by Facebook for building user interfaces. It uses a component-based architecture and a virtual DOM for efficient renderi...

Q

What is JSX?

JSX stands for JavaScript XML. It is a syntax extension that lets you write HTML-like code inside JavaScript. JSX is transpiled to React.createElement() calls b...

Q

What is the Virtual DOM?

The Virtual DOM is a lightweight in-memory representation of the real DOM. When state changes, React creates a new virtual DOM tree, diffs it against the previo...

Q

What is a functional component in React?

A functional component is a plain JavaScript function that accepts props as an argument and returns JSX. Example:function Greeting({ name }) { return <h1>...