### Summary Similarly to what has been done on the `react-native` repo in https://github.com/facebook/react-native/pull/43851, this PR adds a `react.code-workspace` workspace file when using VSCode. This disables the built-in TypeScript Language Service for `.js`, `.ts`, and `.json` files, recommends extensions, enables `formatOnSave`, excludes certain files in search, and configures Flow language support. ### Motivation This is a DevX benefit for **React contributors** using open source VS Code. Without this, it takes quite a long time to set up the environment in vscode to work well. For me the following two points took around an hour each to figure out, but for others it may take even more (screenshots can be found below): * Search with "files to include" was searching in ignored files (compiled/generated) * Configure language validation and prettier both in "packages" that use flow and in the "compiler" folder that uses typescript. ### Recommended extensions NOTE: The recommended extensions list is currently minimal — happy to extend this now or in future, but let's aim to keep these conservative at the moment. * Flow — language support * EditorConfig — formatting based on `.editorconfig`, all file types * Prettier — formatting for JS* files * ESLint — linter for JS* files ### Why `react.code-workspace`? `.code-workspace` files have slight extra behaviours over a `.vscode/` directory: * Allows user to opt-in or skip. * Allows double-click launching from file managers. * Allows base folder (and any subfolders in future) to be opened with local file tree scope (useful in fbsource!) * (Minor point) Single config file over multiple files. https://code.visualstudio.com/docs/editor/workspaces ### Test plan Against a new un-configured copy of Visual Studio Code Insiders. **Without workspace config** ❌ .js files raise errors by default (built-in TypeScript language service) ❌ When using the Flow VS Code extension, the wrong version (global) of Flow is used. <img width="978" alt="Screenshot 2024-06-10 at 16 03 59" src="https://github.com/facebook/react/assets/5188459/17e19ba4-bac2-48ea-9b35-6b4b6242bcc1"> ❌ Searching in excluded files when the "include" field is specified <img width="502" alt="Screenshot 2024-06-10 at 15 41 24" src="https://github.com/facebook/react/assets/5188459/00248755-7905-41bc-b303-498ddba82108"> **With workspace config** ✅ Built-in TypeScript Language Service is disabled for .js files, but still enabled for .ts[x] files  ✅ Flow language support is configured correctly against flow version in package.json <img width="993" alt="Screenshot 2024-06-10 at 16 03 44" src="https://github.com/facebook/react/assets/5188459/b54e143c-a013-4e73-8995-3af7b5a03e36"> ✅ Does not search in excluded files when the "include" field is specified <img width="555" alt="Screenshot 2024-06-10 at 15 39 18" src="https://github.com/facebook/react/assets/5188459/dd3e5344-84fb-4b5d-8689-4c8bd28168e0"> ✅ Workspace config is suggested when folder is opened in VS Code  ✅ Dialog is shown on workspace launch with recommended VS Code extensions <img width="580" alt="Screenshot 2024-06-10 at 15 40 52" src="https://github.com/facebook/react/assets/5188459/c6406fb6-92a0-47f1-8497-4ffe899bb6a9"> |
||
|---|---|---|
| .circleci | ||
| .codesandbox | ||
| .github | ||
| compiler | ||
| fixtures | ||
| packages | ||
| scripts | ||
| .editorconfig | ||
| .eslintignore | ||
| .eslintrc.js | ||
| .git-blame-ignore-revs | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| .nvmrc | ||
| .prettierignore | ||
| .prettierrc.js | ||
| .watchmanconfig | ||
| babel.config.js | ||
| CHANGELOG-canary.md | ||
| CHANGELOG.md | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| dangerfile.js | ||
| LICENSE | ||
| netlify.toml | ||
| package.json | ||
| react.code-workspace | ||
| ReactVersions.js | ||
| README.md | ||
| SECURITY.md | ||
| yarn.lock | ||
React ·

React is a JavaScript library for building user interfaces.
- Declarative: React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable, simpler to understand, and easier to debug.
- Component-Based: Build encapsulated components that manage their own state, then compose them to make complex UIs. Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep the state out of the DOM.
- Learn Once, Write Anywhere: We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code. React can also render on the server using Node and power mobile apps using React Native.
Learn how to use React in your project.
Installation
React has been designed for gradual adoption from the start, and you can use as little or as much React as you need:
- Use Quick Start to get a taste of React.
- Add React to an Existing Project to use as little or as much React as you need.
- Create a New React App if you're looking for a powerful JavaScript toolchain.
Documentation
You can find the React documentation on the website.
Check out the Getting Started page for a quick overview.
The documentation is divided into several sections:
- Quick Start
- Tutorial
- Thinking in React
- Installation
- Describing the UI
- Adding Interactivity
- Managing State
- Advanced Guides
- API Reference
- Where to Get Support
- Contributing Guide
You can improve it by sending pull requests to this repository.
Examples
We have several examples on the website. Here is the first one to get you started:
import { createRoot } from 'react-dom/client';
function HelloMessage({ name }) {
return <div>Hello {name}</div>;
}
const root = createRoot(document.getElementById('container'));
root.render(<HelloMessage name="Taylor" />);
This example will render "Hello Taylor" into a container on the page.
You'll notice that we used an HTML-like syntax; we call it JSX. JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML.
Contributing
The main purpose of this repository is to continue evolving React core, making it faster and easier to use. Development of React happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving React.
Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.
Contributing Guide
Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to React.
Good First Issues
To help you get your feet wet and get you familiar with our contribution process, we have a list of good first issues that contain bugs that have a relatively limited scope. This is a great place to get started.
License
React is MIT licensed.