Introduction to the React Repository
Relevant source files
The following files were used as context for generating this wiki page:React is a JavaScript library for building user interfaces. The main purpose of this repository is to continue evolving React core, making it faster and easier to use. It is developed in the open on GitHub, welcoming community contributions for bugfixes and improvements.
React's design is centered on three core principles:
- Declarative: React allows developers to design simple views for each state in an application. It efficiently updates and renders only the necessary components when data changes, making code more predictable and easier to debug.
- Component-Based: The library encourages building encapsulated components that manage their own state. These components can be composed to create complex UIs. Component logic is written in JavaScript, enabling rich data to be passed through the application while keeping state out of the DOM.
- Learn Once, Write Anywhere: React can be integrated into existing projects without requiring a full rewrite. It can render on the server using Node.js and power mobile applications via React Native.
Sources: README.md:9-20, 46-48
Repository Structure and Key Packages
The React repository is a monorepo containing multiple packages within the packages/ directory. This structure allows for modular development and management of the core library and its related tools.
| Package Name | Description | Source File |
|---|---|---|
react | The core React library for building user interfaces. | packages/react/package.json:2-3 |
react-dom | The package for working with the DOM, providing client and server rendering capabilities. | packages/react-dom/package.json:3-4 |
react-reconciler | An experimental package for creating custom React renderers for different host environments. | packages/react-reconciler/README.md:3-6 |
react-is | Provides utilities for brand checking of React Elements. | packages/react-is/package.json:3-4 |
react-markup | A package for generating embedded markup, such as e-mails, with support for Server Components. | packages/react-markup/package.json:3-4 |
jest-react | Provides Jest matchers and utilities for testing React components. | packages/jest-react/package.json:3-4 |
react-devtools | The developer tools for inspecting React component hierarchies. | packages/react-devtools/CONTRIBUTING.md:3-4 |
Contributing to React
Contributions to the React project are managed through a structured process outlined in the repository's contribution guides. All participants are expected to adhere to the project's Code of Conduct.
The general contribution flow involves identifying an issue, proposing changes, and submitting a pull request. The project maintains a list of "good first issues" for newcomers to get familiar with the contribution process.
Sources: README.md:46-59, CONTRIBUTING.md:3-5
Contributing to React DevTools
The process for contributing to React DevTools is a specific workflow that involves setting up the development environment, building local versions of React, and testing changes.
The following diagram illustrates the DevTools contribution workflow:
This diagram shows the steps a contributor would take to set up their environment and test changes for React DevTools.
Sources: packages/react-devtools/CONTRIBUTING.md:6-41
The Release Process
React's release process is a combination of automated continuous integration and manual steps, designed to publish prereleases frequently and promote stable versions methodically.
Release Channels
- Prereleases (
next,experimental): These are published automatically by a CI cron job on weekdays from themainbranch. They can also be triggered manually.experimentalreleases contain additional features not present innext. - Stable (
latest): Stable releases are always promoted from an existingnextversion. This process is manual and involves updating version numbers and publishing with thelatesttag on NPM.
Sources: scripts/release/README.md:10-25, 62-67
Release Workflow
The diagram below outlines the high-level release cycle for React.
This flow shows how commits to main lead to automated prereleases, which are then manually promoted to stable releases.
Sources: scripts/release/README.md:28-40, 81-91
Advanced Tooling
The repository contains advanced internal tooling to aid in development, optimization, and documentation.
React Compiler MCP Server
A key piece of internal tooling is the React Compiler Model Context Protocol (MCP) Server. This server provides a set of tools to assist developers in writing and optimizing React code.
The server and its available tools are depicted below:
This diagram shows the MCP Server and the tools it exposes for various development tasks.
Sources: compiler/packages/react-mcp-server/src/index.ts:25-27
The tools provided by the server include:
| Tool Name | Description |
|---|---|
query-react-dev-docs | Searches the official react.dev documentation for information on APIs and hooks. |
compile | Compiles React code with the React Compiler to check for successful memoization and optimization. It can return the compiled code and diagnostic messages. |
review-react-runtime | Measures the performance of React code by analyzing metrics like LCP, INP, and CLS to verify that changes improve performance. |
parse-react-component-tree | Connects to a running application in a browser and retrieves the current state of the React component tree. |
Sources: compiler/packages/react-mcp-server/src/index.ts:40-43, 81-87, 222-225, 301-305
Core Architectural Concepts
The React Reconciler
The react-reconciler package is a fundamental part of React's architecture that allows for the creation of custom renderers. It decouples the core reconciliation logic (diffing the component tree) from the target platform (like DOM, Native, or Canvas).
To create a custom renderer, a developer provides a "Host Config" object that tells the reconciler how to interact with the host environment.
This diagram illustrates that the Reconciler, when combined with a specific Host Config, produces a custom renderer.
The reconciler supports two primary modes:
- Mutation Mode: Used for platforms where the host tree is mutable (e.g., DOM's
appendChild). - Persistent Mode: Used for platforms with immutable data structures, where changes result in cloning the parent tree.
Sources: packages/react-reconciler/README.md:3-6, 47-66
Conclusion
The React repository is a sophisticated monorepo dedicated to the advancement of the React library. It encompasses not only the core react and react-dom packages but also a rich ecosystem of tools for development, testing, and releasing. With a well-defined contribution process, an automated release pipeline for prereleases, and powerful internal tooling like the React Compiler server, the repository is structured for both stability and rapid innovation. The architectural design, centered around a pluggable reconciler, ensures React's adaptability across diverse platforms.