mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
b6a32d1e0e1145a58d422811674beae478b8ca40
In https://github.com/facebook/react/pull/34462 for example, we found an issue where the compiler was incorrectly validating an example straight from the docs. In order to find more issues like this + also provide more feedback to doc authors on valid/invalid patterns, this PR adds a new local eslint rule which validates all markdown codeblocks containing components/hooks with React Compiler. An autofixer is also provided. To express that a codeblock has an expected error, we can use the following metadata: ```ts // pseudo type def type MarkdownCodeBlockMetadata = { expectedErrors?: { 'react-compiler'?: number[]; }; }; ``` and can be used like so: ```` ```js {expectedErrors: {'react-compiler': [4]}} // ❌ setState directly in render function Component({value}) { const [count, setCount] = useState(0); setCount(value); // error on L4 return <div>{count}</div>; } ``` ```` Because this is defined as a local rule, we don't have the same granular reporting that `eslint-plugin-react-hooks` yet. I can look into that later but for now this first PR just sets us up with something basic.
react.dev
This repo contains the source code and documentation powering react.dev.
Getting started
Prerequisites
- Git
- Node: any version starting with v16.8.0 or greater
- Yarn: See Yarn website for installation instructions
- A fork of the repo (for any contributions)
- A clone of the react.dev repo on your local machine
Installation
cd react.devto go into the project rootyarnto install the website's npm dependencies
Running locally
yarn devto start the development server (powered by Next.js)open http://localhost:3000to open the site in your favorite browser
Contributing
Guidelines
The documentation is divided into several sections with a different tone and purpose. If you plan to write more than a few sentences, you might find it helpful to get familiar with the contributing guidelines for the appropriate sections.
Create a branch
git checkout mainfrom any folder in your localreact.devrepositorygit pull origin mainto ensure you have the latest main codegit checkout -b the-name-of-my-branch(replacingthe-name-of-my-branchwith a suitable name) to create a branch
Make the change
- Follow the "Running locally" instructions
- Save the files and check in the browser
- Changes to React components in
srcwill hot-reload - Changes to markdown files in
contentwill hot-reload - If working with plugins, you may need to remove the
.cachedirectory and restart the server
Test the change
- If possible, test any visual changes in all latest versions of common browsers, on both desktop and mobile.
- Run
yarn check-all. (This will run Prettier, ESLint and validate types.)
Push it
git add -A && git commit -m "My message"(replacingMy messagewith a commit message, such asFix header logo on Android) to stage and commit your changesgit push my-fork-name the-name-of-my-branch- Go to the react.dev repo and you should see recently pushed branches.
- Follow GitHub's instructions.
- If possible, include screenshots of visual changes. A preview build is triggered after your changes are pushed to GitHub.
Translation
If you are interested in translating react.dev, please see the current translation efforts here.
License
Content submitted to react.dev is CC-BY-4.0 licensed, as found in the LICENSE-DOCS.md file.
Description
Languages
TypeScript
59.1%
JavaScript
34.6%
CSS
6.1%
HTML
0.2%