How to Contribute
Relevant source files
The following files were used as context for generating this wiki page:- CONTRIBUTING.md
- README.md
- packages/react-devtools/CONTRIBUTING.md
- scripts/release/README.md
- dangerfile.js
- CODE_OF_CONDUCT.md
- compiler/scripts/update-commit-message.js
- scripts/release/publish-commands/print-follow-up-instructions.js
- packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ReportNewIssue.js
Contributing to React involves a range of activities, from fixing bugs and improving documentation to developing new features. The development of React happens openly on GitHub, and the project relies on community contributions. This guide provides an overview of the contribution process, from setting up your environment to submitting pull requests and understanding the release cycle.
All participants are expected to adhere to the project's Code of Conduct. For a comprehensive guide, please refer to the official Contributing Guide.
Sources: README.md:52-54, CONTRIBUTING.md:3-5
General Contribution Workflow
The following diagram illustrates the high-level workflow for contributing to the React project.
This diagram shows the general path from finding an issue to getting a pull request merged.
Sources: README.md:60-63, packages/react-devtools/CONTRIBUTING.md:4-8
Getting Started
Code of Conduct
All contributors must adhere to the project's Code of Conduct. The core principles are to foster an open, welcoming, and harassment-free environment.
Expected Behaviors:
- Using welcoming and inclusive language.
- Being respectful of different viewpoints.
- Accepting constructive criticism gracefully.
- Focusing on what is best for the community.
Instances of unacceptable behavior can be reported to opensource-conduct@fb.com.
Sources: CODE_OF_CONDUCT.md:5-43
Finding an Issue
A great way to start contributing is by tackling a "good first issue". These are bugs with a relatively limited scope, designed to help new contributors get familiar with the process.
- React Core: Good first issues for the core library
- React DevTools: Good first issues for Developer Tools
Sources: README.md:60-63, packages/react-devtools/CONTRIBUTING.md:51-53
Reporting Bugs
If you encounter a bug, particularly within React DevTools, you can report it. The system generates a GitHub issue link with pre-filled information.
The following table details the parameters used to construct the bug report URL for DevTools.
| Parameter | Description |
|---|---|
template | The GitHub issue template to use (e.g., devtools_bug_report.yml). |
labels | A comma-separated list of labels (e.g., Component: Developer Tools, Type: Bug). |
title | The pre-filled title of the issue. |
automated_package | The DevTools package where the error occurred. |
automated_version | The version of the DevTools package. |
automated_error_message | The error message from the exception. |
automated_call_stack | The JavaScript call stack. |
automated_component_stack | The React component stack. |
automated_github_query_string | A pre-generated search query for similar issues on GitHub. |
Sources: packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ReportNewIssue.js:25-45
Development Environment Setup
Core Repository Setup
To begin, clone the React repository and install the necessary dependencies.
git clone git@github.com:facebook/react.git
cd react
yarn install
Sources: packages/react-devtools/CONTRIBUTING.md:4-8
React DevTools Contribution
Contributing to React DevTools requires a specific setup process to build its dependencies.
The diagram below outlines the setup and testing workflow for React DevTools.
This diagram shows the two options for building React dependencies for DevTools and the three primary methods for testing changes.
Sources: packages/react-devtools/CONTRIBUTING.md:10-49
The Pull Request Process
Commit Messages
When using ghstack, commit messages are automatically formatted. The update-commit-message.js script is used via git filter-branch to rewrite commit messages based on the associated pull request.
The following diagram shows how the script processes a commit message.
This sequence diagram illustrates how update-commit-message.js fetches pull request data from GitHub to create a clean and well-formatted commit message.
Sources: compiler/scripts/update-commit-message.js
Automated Checks: Bundle Size (dangerfile.js)
All pull requests are checked by DangerJS to monitor changes in bundle size. This helps prevent unintentional increases in the size of critical React artifacts. The check compares artifacts from the PR's head commit against the base commit.
The logic of the bundle size check is as follows:
This flowchart shows the process of comparing bundle sizes between the base and head of a pull request and reporting the results.
Sources: dangerfile.js
The report categorizes changes as "Critical" or "Significant" based on predefined thresholds.
| Threshold | Value | Description |
|---|---|---|
CRITICAL_THRESHOLD | 2% (0.02) | Changes exceeding this are listed in the top "Critical" section. |
SIGNIFICANCE_THRESHOLD | 0.2% (0.002) | Changes exceeding this are listed in the collapsed "Significant" section. |
Sources: dangerfile.js:33-34
A set of CRITICAL_ARTIFACT_PATHS are always reported, regardless of their size change, to ensure visibility into the most important production bundles.
Sources: dangerfile.js:35-43
Release Process
The release process is managed by a set of scripts located in scripts/release. Most prereleases are handled automatically by CI, but stable and patch releases are manual processes.
Release Scripts
The following scripts are used to manage the release lifecycle.
| Script | Description |
|---|---|
build-release-locally | Creates a "next" build from the local Git revision. This is an escape hatch and does not run automated tests. |
prepare-release-from-ci | Downloads pre-tested build artifacts from CI for a specific commit to be published as "next" or "experimental". |
prepare-release-from-npm | Prepares an existing "next" release from npm to be promoted to a "stable" release. It prompts for new version numbers. |
publish | Publishes the contents of build/node_modules to npm with specified tags (e.g., next, latest). |
Sources: scripts/release/README.md:120-179
Release Promotion Flow (Next to Stable)
Promoting a next release to stable is a manual process that ensures only well-tested artifacts are published as the latest version.
This diagram outlines the steps required to take a pre-release version from the next channel on npm and publish it as a latest stable release.
Sources: scripts/release/README.md:79-94, scripts/release/publish-commands/print-follow-up-instructions.js:38-70
After a stable release is published, the print-follow-up-instructions.js script provides the necessary Git commands to tag the release and a link to create the release notes on GitHub.
Sources: scripts/release/publish-commands/print-follow-up-instructions.js:58-66