diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index de2bfc362..ab8a7d4fe 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -3,5 +3,5 @@ contact_links: url: https://github.com/react/react/issues/new/choose about: This issue tracker is not for bugs in React. Please file React issues here. - name: 🤔 Questions and Help - url: https://reactjs.org/community/support.html + url: https://react.dev/community about: This issue tracker is not for support questions. Please refer to the React community's help and discussion forums. diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index 83e7f2e8a..1620c50f6 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -18,7 +18,7 @@ jobs: - name: Set up node uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: '24.x' cache: yarn cache-dependency-path: yarn.lock @@ -26,7 +26,7 @@ jobs: uses: actions/cache@v4 with: path: '**/node_modules' - key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + key: node_modules-24-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} - name: Install deps run: yarn install --frozen-lockfile diff --git a/.github/workflows/site_lint.yml b/.github/workflows/site_lint.yml index 26d7ed583..02812d6fd 100644 --- a/.github/workflows/site_lint.yml +++ b/.github/workflows/site_lint.yml @@ -13,14 +13,14 @@ jobs: lint: runs-on: ubuntu-latest - name: Lint on node 20.x and ubuntu-latest + name: Lint on node 24.x and ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Use Node.js 20.x + - name: Use Node.js 24.x uses: actions/setup-node@v4 with: - node-version: 20.x + node-version: 24.x cache: yarn cache-dependency-path: yarn.lock @@ -28,7 +28,7 @@ jobs: uses: actions/cache@v4 with: path: '**/node_modules' - key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + key: node_modules-24-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} - name: Install deps run: yarn install --frozen-lockfile diff --git a/CLAUDE.md b/CLAUDE.md index 3a081e6d5..3943097cc 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,7 @@ This file provides guidance to Claude Code when working with this repository. ## Project Overview -This is the React documentation website (react.dev), built with Next.js 15.1.11 and React 19. Documentation is written in MDX format. +This is the React documentation website (react.dev), built with Next.js 15.1.12 and React 19. Documentation is written in MDX format. ## Development Commands @@ -47,6 +47,6 @@ When editing files in `src/content/`, the appropriate skill will be auto-suggest For MDX components (DeepDive, Pitfall, Note, etc.), invoke `/docs-components`. For Sandpack code examples, invoke `/docs-sandpack`. -See `.claude/docs/react-docs-patterns.md` for comprehensive style guidelines. +See `.claude/skills/` for comprehensive style guidelines. Prettier is used for formatting (config in `.prettierrc`). diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index f049d4c53..14e553ed8 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -55,8 +55,9 @@ a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at . All -complaints will be reviewed and investigated and will result in a response that +reported by following the +[reporting instructions in React's Code of Conduct](https://github.com/react/react/blob/main/CODE_OF_CONDUCT.md#enforcement). +All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c7e5ec74..b6306c145 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,9 +4,7 @@ Thank you for your interest in contributing to the React Docs! ## Code of Conduct -Facebook has adopted a Code of Conduct that we expect project -participants to adhere to. Please [read the full text](https://code.facebook.com/codeofconduct) -so that you can understand what actions will and will not be tolerated. +We expect all project participants to follow our [Code of Conduct](./CODE_OF_CONDUCT.md). ## Technical Writing Tips @@ -38,41 +36,9 @@ Ignore this if you're specifically describing `createElement`. Ignore this if you're specifically writing about ES5. -#### Don't use ES6 features when equivalent ES5 features have no downsides. +#### Prefer readable syntax. -Remember that ES6 is still new to a lot of people. While we use it in many places (`const` / `let`, classes, arrow functions), if the equivalent ES5 code is just as straightforward and readable, consider using it. - -In particular, you should prefer named `function` declarations over `const myFunction = () => ...` arrows for top-level functions. However, you *should* use arrow functions where they provide a tangible improvement (such as preserving `this` context inside a component). Consider both sides of the tradeoff when deciding whether to use a new feature. - -#### Don't use features that aren't standardized yet. - -For example, **don't** write this: - -```js -class MyComponent extends React.Component { - state = {value: ''}; - handleChange = (e) => { - this.setState({value: e.target.value}); - }; -} -``` - -Instead, **do** write this: - -```js -class MyComponent extends React.Component { - constructor(props) { - super(props); - this.handleChange = this.handleChange.bind(this); - this.state = {value: ''}; - } - handleChange(e) { - this.setState({value: e.target.value}); - } -} -``` - -Ignore this rule if you're specifically describing an experimental proposal. Make sure to mention its experimental nature in the code and in the surrounding text. +Choose syntax that makes each example easier to follow. Prefer named `function` declarations over `const myFunction = () => ...` arrows for top-level functions. Use arrow functions when they make callbacks easier to read. In class components, arrow functions can also preserve the component's `this` value. ### Style diff --git a/README.md b/README.md index fc38243c4..595e4b8df 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,26 @@ This repo contains the source code and documentation powering [react.dev](https://react.dev/). +<<<<<<< HEAD > 以下はオリジナル(英語版)リポジトリの README です。日本語版 React ドキュメントへの貢献(翻訳・修正など)に興味がある方は[こちらの Wiki ページ](https://github.com/reactjs/ja.react.dev/wiki)を参照してください。 +======= +React is a project of the [React Foundation](https://react.foundation/), hosted by the [Linux Foundation](https://www.linuxfoundation.org/). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ## Getting started ### Prerequisites 1. Git -1. Node: any version starting with v16.8.0 or greater -1. Yarn: See [Yarn website for installation instructions](https://yarnpkg.com/lang/en/docs/install/) +1. Node: v24 or greater +1. Yarn Classic: See [Yarn website for installation instructions](https://classic.yarnpkg.com/en/docs/install/) 1. A fork of the repo (for any contributions) 1. A clone of the [react.dev repo](https://github.com/reactjs/react.dev) on your local machine ### Installation 1. `cd react.dev` to go into the project root +2. `git remote add my-fork-name https://github.com/YOUR_USERNAME/react.dev.git` to add your fork as a remote. Replace `YOUR_USERNAME` with your GitHub username. You only need to do this once. 3. `yarn` to install the website's npm dependencies ### Running locally @@ -41,8 +46,8 @@ The documentation is divided into several sections with a different tone and pur 1. Follow the ["Running locally"](#running-locally) instructions 1. Save the files and check in the browser 1. Changes to React components in `src` will hot-reload - 1. Changes to markdown files in `content` will hot-reload - 1. If working with plugins, you may need to remove the `.cache` directory and restart the server + 1. Changes to markdown files in `src/content` will hot-reload + 1. If working with plugins, you may need to remove the `node_modules/.cache/react-docs-mdx` directory and restart the server ### Test the change @@ -59,7 +64,7 @@ The documentation is divided into several sections with a different tone and pur ## Translation -If you are interested in translating `react.dev`, please see the current translation efforts [here](https://github.com/reactjs/react.dev/issues/4135). +If you are interested in translating `react.dev`, please see the current translation efforts [here](https://react.dev/community/translations). ## License Content submitted to [react.dev](https://react.dev/) is CC-BY-4.0 licensed, as found in the [LICENSE-DOCS.md](https://github.com/reactjs/react.dev/blob/main/LICENSE-DOCS.md) file. \ No newline at end of file diff --git a/package.json b/package.json index 39d2119ff..e8bfaebb6 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "webpack-bundle-analyzer": "^4.5.0" }, "engines": { - "node": ">=16.8.0" + "node": ">=24" }, "nextBundleAnalysis": { "budget": null, diff --git a/public/images/brand/react-foundation-dark.svg b/public/images/brand/react-foundation-dark.svg new file mode 100644 index 000000000..bc5658e03 --- /dev/null +++ b/public/images/brand/react-foundation-dark.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/images/brand/react-foundation-light.svg b/public/images/brand/react-foundation-light.svg new file mode 100644 index 000000000..74f7aca68 --- /dev/null +++ b/public/images/brand/react-foundation-light.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/Layout/Footer.tsx b/src/components/Layout/Footer.tsx index 0ef9ac941..8fccdbc21 100644 --- a/src/components/Layout/Footer.tsx +++ b/src/components/Layout/Footer.tsx @@ -11,6 +11,7 @@ import * as React from 'react'; import NextLink from 'next/link'; +import Image from 'next/image'; import cn from 'classnames'; import {ExternalLink} from 'components/ExternalLink'; import {IconFacebookCircle} from 'components/Icon/IconFacebookCircle'; @@ -25,273 +26,30 @@ export function Footer() {
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ href="https://react.foundation/" + aria-label="React Foundation" + className="block w-fit"> + +
- Copyright © Meta Platforms, Inc + Copyright © React a Series of LF Projects, LLC and its + contributors.
More ブログ React Native +<<<<<<< HEAD プライバシー 利用規約 +======= + + Privacy + + + Terms +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 + + + Policies
- +
@@ -124,7 +124,7 @@ export function TeamMember({ aria-label={`${name} on Threads`} href={`https://threads.net/${threads}`} className="hover:text-primary hover:underline dark:text-primary-dark flex flex-row items-center"> - +
@@ -135,7 +135,7 @@ export function TeamMember({ aria-label={`${name} on Bluesky`} href={`https://bsky.app/profile/${bsky}`} className="hover:text-primary hover:underline dark:text-primary-dark flex flex-row items-center"> - +
@@ -143,19 +143,19 @@ export function TeamMember({ {github && (
- {github} +
)} {personal && ( - {personal} + )}
diff --git a/src/content/blog/2023/03/16/introducing-react-dev.md b/src/content/blog/2023/03/16/introducing-react-dev.md index 37ada4468..4eec7b4be 100644 --- a/src/content/blog/2023/03/16/introducing-react-dev.md +++ b/src/content/blog/2023/03/16/introducing-react-dev.md @@ -41,8 +41,13 @@ March 16, 2023 by [Dan Abramov](https://bsky.app/profile/danabra.mov) and [Rache **新しいドキュメントでは、最初からフックを用いて React を学びます**。ドキュメントは主に 2 つのセクションに分かれています。 +<<<<<<< HEAD * **[React を学ぶ](/learn)** は、ゼロから React を学ぶ自己学習型のコースです。 * **[API リファレンス](/reference)** では、すべての React API の詳細と使い方のサンプルが提供されています。 +======= +* **[Learn React](/learn)** is a self-paced course that teaches React from scratch. +* **[API Reference](/reference/react)** provides the details and usage examples for every React API. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 それぞれのセクションで見ることができる内容を詳しく見ていきましょう。 @@ -459,11 +464,19 @@ export default function PackingList() { [API リファレンス](/reference/react) では、すべての React API に専用のページが用意されています。これにはあらゆる種類の API が含まれます: +<<<<<<< HEAD - 組み込みフックである [`useState`](/reference/react/useState) など。 - 組み込みコンポーネントである [``](/reference/react/Suspense) など。 - 組み込みブラウザコンポーネントである [``](/reference/react-dom/components/input) など。 - フレームワーク向けの API である [`renderToPipeableStream`](/reference/react-dom/server/renderToReadableStream) など。 - その他の React API である [`memo`](/reference/react/memo) など。 +======= +- Built-in Hooks like [`useState`](/reference/react/useState). +- Built-in components like [``](/reference/react/Suspense). +- Built-in browser components like [``](/reference/react-dom/components/input). +- Framework-oriented APIs like [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream). +- Other React APIs like [`memo`](/reference/react/memo). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 各 API ページは少なくとも*リファレンス*と*使用法*の 2 つのセグメントに分かれていることに気付くでしょう。 @@ -607,7 +620,11 @@ button { display: block; margin-top: 10px; } +<<<<<<< HEAD 一部の API ページには、(よくある問題に対する)[トラブルシューティング](/reference/react/useEffect#troubleshooting)や、(非推奨の API に対する)[代替手段](/reference/react-dom/findDOMNode#alternatives)のセクションも含まれています。 +======= +Some API pages also include [Troubleshooting](/reference/react/useEffect#troubleshooting) (for common problems) and [Alternatives](https://18.react.dev/reference/react-dom/findDOMNode#alternatives) (for deprecated APIs). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 このアプローチにより、API リファレンスが引数を調べる手段としてだけでなく、その API を使用してどれだけ色々なことができるのか、他の API とどのように繋がっているのかを示す手段として役立つことを願っています。 diff --git a/src/content/blog/2024/04/25/react-19-upgrade-guide.md b/src/content/blog/2024/04/25/react-19-upgrade-guide.md index 924af33d6..63180b756 100644 --- a/src/content/blog/2024/04/25/react-19-upgrade-guide.md +++ b/src/content/blog/2024/04/25/react-19-upgrade-guide.md @@ -639,7 +639,11 @@ const ref = useRef(null); ref.current = 1; ``` +<<<<<<< HEAD `MutableRef` は廃止され、`useRef` は常に単一の `RefObject` 型を返すようになりました。 +======= +`MutableRefObject` is now deprecated in favor of a single `RefObject` type which `useRef` will always return: +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ```ts interface RefObject { diff --git a/src/content/blog/2024/12/05/react-19.md b/src/content/blog/2024/12/05/react-19.md index 4c9538f26..0cc026731 100644 --- a/src/content/blog/2024/12/05/react-19.md +++ b/src/content/blog/2024/12/05/react-19.md @@ -389,7 +389,11 @@ React Server Components をバンドラやフレームワークでサポート サーバアクションをサーバコンポーネント内で作成し props としてクライアントコンポーネントに渡すことも、クライアントコンポーネントでインポートして使用することもできます。 +<<<<<<< HEAD 詳細については、[React サーバアクション](/reference/rsc/server-actions)のドキュメントをご覧ください。 +======= +For more, see the docs for [React Server Actions](/reference/rsc/server-functions). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ## React 19 の改善点 {/*improvements-in-react-19*/} diff --git a/src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md b/src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md index 116a28943..0d7c7c839 100644 --- a/src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md +++ b/src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md @@ -14266,7 +14266,11 @@ Activity の別のモードとして我々が考慮しているのは、メモ 多くの場合に混乱の原因は、必要もなくエフェクトが使われていることにあるとわかりました。[そのエフェクトは不要かも](/learn/you-might-not-need-an-effect)のガイドは、エフェクトがソリューションとして適切ではないパターンの多くをカバーしています。しかし、ある問題に対してエフェクトが適切であるという場合ですら、エフェクトはクラスコンポーネントのライフサイクルよりも理解しにくい場合があります。 +<<<<<<< HEAD 混乱の一因は、開発者がエフェクトをエフェクト自体の視点(エフェクトが何をするか)ではなく、ライフサイクルのような*コンポーネント*の視点から考えてしまっていることにあると考えています。 +======= +We believe one of the reasons for confusion is that developers tend to think of Effects from the _component's_ perspective (like a lifecycle), instead of the _Effects_ point of view (what the Effect does). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 [ドキュメントにあるこちらの例](/learn/lifecycle-of-reactive-effects#thinking-from-the-effects-perspective)を見てみましょう。 diff --git a/src/content/blog/2025/12/11/denial-of-service-and-source-code-exposure-in-react-server-components.md b/src/content/blog/2025/12/11/denial-of-service-and-source-code-exposure-in-react-server-components.md index aeed7cae9..5a301268f 100644 --- a/src/content/blog/2025/12/11/denial-of-service-and-source-code-exposure-in-react-server-components.md +++ b/src/content/blog/2025/12/11/denial-of-service-and-source-code-exposure-in-react-server-components.md @@ -76,7 +76,11 @@ _Updated January 26, 2026._ ### 影響を受けるフレームワークとバンドラ {/*affected-frameworks-and-bundlers*/} +<<<<<<< HEAD 一部の React フレームワークやバンドラが、脆弱性のある React パッケージに依存しているか、peer dependency として依存しているか、あるいはそれらを含んでいました。影響を受ける React フレームワークやバンドラは以下の通りです:[next](https://www.npmjs.com/package/next)、[react-router](https://www.npmjs.com/package/react-router)、[waku](https://www.npmjs.com/package/waku)、[@parcel/rsc](https://www.npmjs.com/package/@parcel/rsc)、[@vite/rsc-plugin](https://www.npmjs.com/package/@vitejs/plugin-rsc)、[rwsdk](https://www.npmjs.com/package/rwsdk) +======= +Some React frameworks and bundlers depended on, had peer dependencies for, or included the vulnerable React packages. The following React frameworks & bundlers are affected: [next](https://www.npmjs.com/package/next), [react-router](https://www.npmjs.com/package/react-router), [waku](https://www.npmjs.com/package/waku), [@parcel/rsc](https://www.npmjs.com/package/@parcel/rsc), [@vitejs/plugin-rsc](https://www.npmjs.com/package/@vitejs/plugin-rsc), and [rwsdk](https://www.npmjs.com/package/rwsdk). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 アップグレード方法について、[前回の記事の手順](/blog/2025/12/03/critical-security-vulnerability-in-react-server-components#update-instructions)を参照してください。 diff --git a/src/content/community/conferences.md b/src/content/community/conferences.md index e5a82ba4c..f65375d28 100644 --- a/src/content/community/conferences.md +++ b/src/content/community/conferences.md @@ -10,26 +10,6 @@ title: React カンファレンス ## Upcoming Conferences {/*upcoming-conferences*/} -### ZurichJS Conf 2026 {/*zurichjs-conf-2026*/} -September 10-11, 2026. In-person in Zurich, Switzerland - -[Website](https://conf.zurichjs.com?utm_campaign=ZurichJS_Conf&utm_source=referral&utm_content=reactjs_community_conferences) - [Twitter](https://x.com/zurichjs) - [LinkedIn](https://www.linkedin.com/company/zurichjs/) - -### React Alicante 2026 {/*react-alicante-2026*/} -Sep 24 - 26, 2026. In-person in Alicante - -[Website](https://reactalicante.es//) - [Twitter](https://x.com/ReactAlicante) - -### CityJS Athens 2026 {/*cityjs-athens-2026*/} -October 21-23, 2026. In-person in Athens - -[Website](https://athens.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) - -### React Advanced London 2026 {/*react-advanced-london-2026*/} -October 23 & 26, 2026. In-person in London, UK + online (hybrid event) - -[Website](https://reactadvanced.com/) - [Twitter](https://x.com/reactadvanced) - [LinkedIn](https://www.linkedin.com/showcase/react-advanced-london/) - ### React Summit US 2026 {/*react-summit-us-2026*/} November 17 & 20, 2026. In-person in New York, USA + online (hybrid event) @@ -45,6 +25,11 @@ April 15 & 19, 2027. In-person in Singapore + online (hybrid event) [Website](https://reactsummit.asia/) - [Twitter](https://x.com/reactsummit) - [LinkedIn](https://www.linkedin.com/showcase/reactsummit) +### React Conf Japan 2027 {/*react-conf-japan-2027*/} +April 24, 2027. In-person in Tokyo, Japan + +[Website](https://reactconf.jp/) - [Twitter](https://x.com/reactconfjp) + ### React Summit 2027 {/*react-summit-2027*/} May 21 & 25, 2027. In-person in Amsterdam, Netherlands + online (hybrid event) @@ -53,16 +38,60 @@ May 21 & 25, 2027. In-person in Amsterdam, Netherlands + online (hybrid event) ## Past Conferences {/*past-conferences*/} +### React India 2026 {/*react-india-2026*/} +October 29-31, 2026. In-person in Goa, India -### React Conf Japan 2027 {/*react-conf-japan-2027*/} -April 24, 2027. In-person in Tokyo, Japan +[Website](https://www.reactindia.io/) - [Twitter](https://x.com/react_india) -[Website](https://reactconf.jp/) - [Twitter](https://x.com/reactconfjp) +### React Advanced London 2026 {/*react-advanced-london-2026*/} +October 23 & 26, 2026. In-person in London, UK + online (hybrid event) + +[Website](https://reactadvanced.com/) - [Twitter](https://x.com/reactadvanced) - [LinkedIn](https://www.linkedin.com/showcase/react-advanced-london/) + +### CityJS Athens 2026 {/*cityjs-athens-2026*/} +October 21-23, 2026. In-person in Athens + +[Website](https://athens.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) + +### React Alicante 2026 {/*react-alicante-2026*/} +Sep 24 - 26, 2026. In-person in Alicante + +[Website](https://reactalicante.es//) - [Twitter](https://x.com/ReactAlicante) + +### React Native Connection 2026 {/*react-native-connection-2026*/} +September 24, 2026. In-person in Paris, France + +[Website](https://reactnativeconnection.io/) - [Twitter](https://x.com/ReactNativeConn) - [Bluesky](https://bsky.app/profile/reactnativeconnect.bsky.social) + +### ZurichJS Conf 2026 {/*zurichjs-conf-2026*/} +September 10-11, 2026. In-person in Zurich, Switzerland + +[Website](https://conf.zurichjs.com?utm_campaign=ZurichJS_Conf&utm_source=referral&utm_content=reactjs_community_conferences) - [Twitter](https://x.com/zurichjs) - [LinkedIn](https://www.linkedin.com/company/zurichjs/) + +### Render(ATL) 2026 🍑 {/*renderatl-2026-*/} +August 12-13, 2026. In-person in Atlanta, GA, USA + +[Website](https://renderatl.com/) - [Twitter](https://x.com/renderATL) - [LinkedIn](https://www.linkedin.com/company/renderatl) + +### React Summit 2026 {/*react-summit-2026*/} +June 12 & 16, 2026. In-person in Amsterdam, Netherlands + online (hybrid event) + +[Website](https://reactsummit.com/) - [Twitter](https://x.com/reactsummit) - [LinkedIn](https://www.linkedin.com/showcase/reactsummit) + +### React Norway 2026 {/*react-norway-2026*/} +June 5, 2026. In-person in Oslo, Norway + +[Website](https://reactnorway.com/) - [Twitter](https://x.com/ReactNorway) + +### React Miami 2026 {/*react-miami-2026*/} +April 23-24, 2026. In-person in Miami, FL, USA + +[Website](https://reactmiami.com/) - [Twitter](https://x.com/ReactMiamiConf) ### CityJS London 2026 {/*cityjs-london-2026*/} April 14-17, 2026. In-person in London -[Website](https://india.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) +[Website](https://london.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) ### React Paris 2026 {/*react-paris-2026*/} @@ -79,7 +108,7 @@ February 12-13, 2026. In-person in New Delhi, India ### CityJS Singapore 2026 {/*cityjs-singapore-2026*/} February 4-6, 2026. In-person in Singapore -[Website](https://india.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) +[Website](https://singapore.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) ### React Advanced London 2025 {/*react-advanced-london-2025*/} November 28 & December 1, 2025. In-person in London, UK + online (hybrid event) diff --git a/src/content/learn/describing-the-ui.md b/src/content/learn/describing-the-ui.md index c294c65f0..dd77fdebb 100644 --- a/src/content/learn/describing-the-ui.md +++ b/src/content/learn/describing-the-ui.md @@ -530,7 +530,11 @@ React はコンポーネント間あるいはモジュール間の関係性を React レンダーツリーとはコンポーネントの親子関係を表現したものです。 +<<<<<<< HEAD +======= + +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 React のレンダーツリーの例 diff --git a/src/content/learn/extracting-state-logic-into-a-reducer.md b/src/content/learn/extracting-state-logic-into-a-reducer.md index ce9413455..8b7bdf8ed 100644 --- a/src/content/learn/extracting-state-logic-into-a-reducer.md +++ b/src/content/learn/extracting-state-logic-into-a-reducer.md @@ -874,7 +874,11 @@ li { - **テスト**:リデューサはコンポーネントに依存しない純関数です。これは、リデューサをエクスポートし、他のものとは別に単体でテストできることを意味します。一般的には、より現実的な環境でコンポーネントをテストするのがベストですが、複雑な state 更新ロジックがある場合は、特定の初期 state とアクションに対してリデューサが特定の state を返すことをテストすることが役立ちます。 - **個人の好み**:人によってリデューサが好きだったり、好きではなかったりします。それで構いません。好みの問題です。`useState` と `useReducer` の間を行ったり来たりすることはいつでも可能です。どちらも同等のものです! +<<<<<<< HEAD バグが頻繁に発生しておりコンポーネントのコードに構造を導入したい場合に、リデューサを利用することをお勧めします。あらゆるコンポーネントにリデューサを使用する必要はありません。自由に組み合わせてください! 同じコンポーネントで `useState` と `useReducer` を両方使うことも可能です。 +======= +We recommend using a reducer if you often encounter bugs due to incorrect state updates in some component, and want to introduce more structure to its code. You don't have to use reducers for everything: feel free to mix and match! You can even use `useState` and `useReducer` in the same component. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ## 良いリデューサの書き方 {/*writing-reducers-well*/} diff --git a/src/content/learn/index.md b/src/content/learn/index.md index 58dfee8b9..0568e75b2 100644 --- a/src/content/learn/index.md +++ b/src/content/learn/index.md @@ -336,7 +336,11 @@ function MyButton() { } ``` +<<<<<<< HEAD React は、再度コンポーネントの関数を呼び出します。今度は `count` が `1` になっています。次の呼び出しでは `2` になっています。次々と増えていきます。 +======= +Calling `setCount` tells React to call your component function again. This is called a *re-render*. This time, `count` will be `1`. Then it will be `2`. And so on. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 同じコンポーネントを複数の場所でレンダーした場合、それぞれが独自の state を持ちます。それぞれのボタンを個別にクリックしてみてください: diff --git a/src/content/learn/lifecycle-of-reactive-effects.md b/src/content/learn/lifecycle-of-reactive-effects.md index cafd8b387..7b8b54e12 100644 --- a/src/content/learn/lifecycle-of-reactive-effects.md +++ b/src/content/learn/lifecycle-of-reactive-effects.md @@ -1375,7 +1375,7 @@ export default function App() { ``` ```js {expectedErrors: {'react-compiler': [8]}} src/ChatRoom.js active -import { useState, useEffect } from 'react'; +import { useEffect } from 'react'; export default function ChatRoom({ roomId, createConnection }) { useEffect(() => { @@ -1473,7 +1473,7 @@ export default function App() { ``` ```js src/ChatRoom.js active -import { useState, useEffect } from 'react'; +import { useEffect } from 'react'; export default function ChatRoom({ roomId, createConnection }) { useEffect(() => { @@ -1561,7 +1561,7 @@ export default function App() { ``` ```js src/ChatRoom.js active -import { useState, useEffect } from 'react'; +import { useEffect } from 'react'; import { createEncryptedConnection, createUnencryptedConnection, diff --git a/src/content/learn/preserving-and-resetting-state.md b/src/content/learn/preserving-and-resetting-state.md index 3e6903acd..a2fa4f1cb 100644 --- a/src/content/learn/preserving-and-resetting-state.md +++ b/src/content/learn/preserving-and-resetting-state.md @@ -18,7 +18,11 @@ state は複数のコンポーネント間で独立しています。React は U ## state はレンダーツリー内の位置に結びついている {/*state-is-tied-to-a-position-in-the-tree*/} +<<<<<<< HEAD React はあなたの UI のコンポーネント構造を[レンダーツリー](learn/understanding-your-ui-as-a-tree#the-render-tree)としてビルドします。 +======= +React builds [render trees](/learn/understanding-your-ui-as-a-tree#the-render-tree) for the component structure in your UI. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 コンポーネントに state を与えると、その state はそのコンポーネントの内部で「生存」しているように思えるかもしれません。しかし、実際には state は React の中に保持されています。React は、「レンダーツリー内でそのコンポーネントがどの位置にあるか」に基づいて、保持している各 state を正しいコンポーネントに関連付けます。 diff --git a/src/content/learn/react-compiler/introduction.md b/src/content/learn/react-compiler/introduction.md index 0527c4730..0465eefbc 100644 --- a/src/content/learn/react-compiler/introduction.md +++ b/src/content/learn/react-compiler/introduction.md @@ -144,7 +144,11 @@ function TableContainer({ items }) { - React Compiler は React コンポーネントとフックのみをメモ化し、すべての関数をメモ化するわけではない - React Compiler のメモ化は複数のコンポーネントやフック間で共有されない +<<<<<<< HEAD そのため、`expensivelyProcessAReallyLargeArrayOfObjects` が多くの異なるコンポーネントで使用される場合、まったく同じ入力が渡されたとしても、その高コストな計算が繰り返し実行されてしまいます。コードをより複雑にする前に、[プロファイリング](reference/react/useMemo#how-to-tell-if-a-calculation-is-expensive)を行って、本当にそれほど高コストかどうかを確認することをお勧めします。 +======= +So if `expensivelyProcessAReallyLargeArrayOfObjects` was used in many different components, even if the same exact items were passed down, that expensive calculation would be run repeatedly. We recommend [profiling](/reference/react/useMemo#how-to-tell-if-a-calculation-is-expensive) first to see if it really is that expensive before making code more complicated. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ## コンパイラを試すべきか? {/*should-i-try-out-the-compiler*/} diff --git a/src/content/learn/setup.md b/src/content/learn/setup.md index 70e91dd8a..b16f0e5d9 100644 --- a/src/content/learn/setup.md +++ b/src/content/learn/setup.md @@ -17,7 +17,11 @@ TypeScript は JavaScript のコードベースに型定義を追加する一般 ## React Developer Tools {/*react-developer-tools*/} +<<<<<<< HEAD React Developer Tools は React コンポーネントの調査を行い、props や state を編集し、パフォーマンスの問題を特定できるブラウザ拡張機能です。インストール方法は[こちら](learn/react-developer-tools)で確認できます。 +======= +React Developer Tools is a browser extension that can inspect React components, edit props and state, and identify performance problems. Learn how to install it [here](/learn/react-developer-tools). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ## React Compiler {/*react-compiler*/} diff --git a/src/content/learn/synchronizing-with-effects.md b/src/content/learn/synchronizing-with-effects.md index 5801fc9fb..c928b32fc 100644 --- a/src/content/learn/synchronizing-with-effects.md +++ b/src/content/learn/synchronizing-with-effects.md @@ -732,8 +732,13 @@ function TodoList() { 上記の欠点は、マウント時にデータをフェッチするのであれば、React に限らずどのライブラリを使う場合でも当てはまる内容です。ルーティングと同様、データフェッチの実装も上手にやろうとすると一筋縄ではいきません。私たちは以下のアプローチをお勧めします。 +<<<<<<< HEAD - **[フレームワーク](/learn/creating-a-react-app#full-stack-frameworks)を使用している場合、組み込みのデータフェッチ機構を使用してください**。モダンな React フレームワークには、効率的で上記の欠点がないデータフェッチ機構が統合されています。 - **それ以外の場合は、クライアントサイドキャッシュの使用や構築を検討してください**。一般的なオープンソースのソリューションには、[TanStack Query](https://tanstack.com/query/latest)、[useSWR](https://swr.vercel.app/)、および [React Router 6.4+](https://beta.reactrouter.com/en/main/start/overview) が含まれます。自分でソリューションを構築することもできます。その場合、エフェクトを内部で使用しつつ、リクエストの重複排除、レスポンスのキャッシュ、ネットワークのウォーターフォールを回避するためのロジック(データのプリロードやルーティング部へのデータ要求の巻き上げ)を追加することになります。 +======= +- **If you use a [framework](/learn/creating-a-react-app#full-stack-frameworks), use its built-in data fetching mechanism.** Modern React frameworks have integrated data fetching mechanisms that are efficient and don't suffer from the above pitfalls. +- **Otherwise, consider using or building a client-side cache.** Popular open source solutions include [TanStack Query](https://tanstack.com/query/latest), [useSWR](https://swr.vercel.app/), and [React Router](https://reactrouter.com/). You can build your own solution too, in which case you would use Effects under the hood, but add logic for deduplicating requests, caching responses, and avoiding network waterfalls (by preloading data or hoisting data requirements to routes). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 これらのアプローチがどちらも適合しない場合は、引き続きエフェクト内で直接データをフェッチすることができます。 diff --git a/src/content/learn/tutorial-tic-tac-toe.md b/src/content/learn/tutorial-tic-tac-toe.md index 52238c980..ddafcc90e 100644 --- a/src/content/learn/tutorial-tic-tac-toe.md +++ b/src/content/learn/tutorial-tic-tac-toe.md @@ -1138,7 +1138,11 @@ JavaScript は[クロージャ](https://developer.mozilla.org/en-US/docs/Web/Jav +<<<<<<< HEAD これで、盤に X を置けるようになりました…が、まだ左上隅のマス目にしか置けません。今の `handleClick` 関数は、左上のマス目に対応するインデックス (`0`) で更新するようハードコードされているからです。`handleClick` を書き換えて、任意のマス目の内容を更新できるようにしましょう。`handleClick` 関数に、更新するマス目のインデックスを指定する引数 `i` を追加します: +======= +Now you can add X's to the board... but only to the upper left square. Your `handleClick` function is hardcoded to update the index for the upper left square (`0`). Let's update `handleClick` to be able to update any square. Add a parameter `i` to the `handleClick` function that takes the index of the square to update: +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ```js {4,6} export default function Board() { diff --git a/src/content/learn/typescript.md b/src/content/learn/typescript.md index 9b04a4a33..865d4ad8e 100644 --- a/src/content/learn/typescript.md +++ b/src/content/learn/typescript.md @@ -335,7 +335,11 @@ function MyComponent() { +<<<<<<< HEAD [`useMemo`](/reference/react/useMemo) フックは、関数呼び出しからの値の作成/再アクセスを行い、2 番目の引数として渡された依存配列が変更されたときにのみ関数を再実行します。フックの呼び出し結果の型は、1 番目の引数として指定した関数の返り値の型から推論されます。フックに型引数を指定することで明示的にすることができます。 +======= +The [`useMemo`](/reference/react/useMemo) Hooks will create/re-access a memoized value from a function call, re-running the function only when dependencies passed as the 2nd parameter are changed. The result of calling the Hook is inferred from the return value from the function in the first parameter. You can be more explicit by providing a type argument to the Hook. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ```ts // The type of visibleTodos is inferred from the return value of filterTodos diff --git a/src/content/learn/understanding-your-ui-as-a-tree.md b/src/content/learn/understanding-your-ui-as-a-tree.md index d2c442cd4..822e1d58c 100644 --- a/src/content/learn/understanding-your-ui-as-a-tree.md +++ b/src/content/learn/understanding-your-ui-as-a-tree.md @@ -135,7 +135,11 @@ React レンダーツリーのルートノードは、アプリの[ルートコ #### レンダーツリー内の HTML タグはどこに? {/*where-are-the-html-elements-in-the-render-tree*/} +<<<<<<< HEAD 上記のレンダーツリーの図には、各コンポーネントがレンダーする HTML タグについては載っていません。これは、レンダーツリーとは React の[コンポーネント](learn/your-first-component#components-ui-building-blocks)だけで構成されるものだからです。 +======= +You'll notice in the above render tree, there is no mention of the HTML tags that each component renders. This is because the render tree is only composed of React [components](/learn/your-first-component#components-ui-building-blocks). +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 UI フレームワークとしての React は特定のプラットフォームに依存しません。react.dev ではウェブへレンダーする例が紹介されており、そこでは UI のプリミティブとして HTML マークアップが使用されます。しかし、React アプリは同様にモバイルやデスクトッププラットフォームにレンダーすることも可能であり、そこでは [UIView](https://developer.apple.com/documentation/uikit/uiview) や [FrameworkElement](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-7.0) のような別の UI プリミティブが使用されるでしょう。 diff --git a/src/content/reference/dev-tools/react-devtools-cdt-mcp.md b/src/content/reference/dev-tools/react-devtools-cdt-mcp.md new file mode 100644 index 000000000..9c966a0ff --- /dev/null +++ b/src/content/reference/dev-tools/react-devtools-cdt-mcp.md @@ -0,0 +1,407 @@ +--- +title: React DevTools for agents +version: experimental +--- + + + +**`react-devtools-cdt-mcp` is experimental.** It is built on the [experimental third-party developer tools API](https://developer.chrome.com/blog/devtools-for-agents-3p-tools) in [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp), and both its tools and their output may change between releases. + + + + + +`react-devtools-cdt-mcp` gives AI coding agents the same view of your app that React DevTools gives you: the component tree, props, hooks, owners, source locations, and render timing. + +```js +import 'react-devtools-cdt-mcp/register'; +``` + + + + + +--- + +## Overview {/*overview*/} + +Coding agents that drive a browser through [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) can click, take snapshots, and read the DOM, but the DOM doesn't tell them which component rendered a button, what state it holds, or why an interaction was slow. + +`react-devtools-cdt-mcp` is a small browser library that you import into the page you're debugging. It registers a group of React tools with the page. When Chrome DevTools MCP connects to that page, it discovers the tools automatically, and your agent can call them like any other MCP tool. + + + +`react-devtools-cdt-mcp` is **not** an MCP server, and it doesn't go in your MCP client config. It runs inside your page. The only MCP server you configure is Chrome DevTools MCP. + + + +--- + +## Setup {/*setup*/} + +#### Install the package {/*install-the-package*/} + + + +npm install --save-dev react-devtools-cdt-mcp + + + +#### Import it before React {/*import-it-before-react*/} + +Import the `register` entry point at the very top of your app's entry file, **before** anything imports `react-dom`: + +```js {1} +import 'react-devtools-cdt-mcp/register'; + +import { createRoot } from 'react-dom/client'; +import App from './App'; + +createRoot(document.getElementById('root')).render(); +``` + +`react-devtools-cdt-mcp` has to load before React does. If you import it after React, the tools won't see your components. + + + +`react-devtools-cdt-mcp` connects to React the same way the React DevTools extension does, and makes React report every commit to it. This slows down your app, so only include it in development builds. + + + +#### Set up Chrome DevTools MCP {/*set-up-chrome-devtools-mcp*/} + +Your agent needs [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) with [third-party developer tools](https://developer.chrome.com/blog/devtools-for-agents-3p-tools) enabled. Follow the [Chrome DevTools MCP docs](https://github.com/ChromeDevTools/chrome-devtools-mcp#getting-started) to set it up. Once your agent opens a page that imports `react-devtools-cdt-mcp/register`, it can list and call the React tools. + +--- + +## Try it {/*try-it*/} + +You don't need an agent to see what the tools return. The sandbox below imports `react-devtools-cdt-mcp/register` exactly as you would in your app, and adds a small **tool console** under the app. The console discovers the React tools the same way Chrome DevTools MCP does, by dispatching the `devtoolstooldiscovery` event, and lets you call them by hand. + +Pick a tool, edit the JSON parameters, and press **Run tool**. Here's a debugging session to follow, playing the agent's part: + +1. **Find a component.** Run `react_find_components` with `{"name": "Row"}`. Each result has a `uid`, like `"r12"`, that the other tools accept. +2. **Inspect it.** Run `react_get_component_by_uid` with one of those uids and `"includeHooks": true` to see its props and hooks. +3. **Start from the screen.** Choose `react_get_component_by_dom_element`, press **Pick element**, and click a product in the list to get the host component that rendered it. +4. **Profile an interaction.** Run `react_start_profiling`, click **Add to cart** in the app, then run `react_stop_profiling`. +5. **See what rendered.** Run `react_get_trace_overview`, then `react_get_commit_report` for commit `0` to see which components rendered in that commit and how long each one took. + + + +```js src/App.js active +import { useState } from 'react'; + +const PRODUCTS = Array.from({ length: 20 }, (_, i) => ({ + id: i, + name: 'Product ' + (i + 1), + price: 10 + i, +})); + +export default function App() { + const [query, setQuery] = useState(''); + const visibleProducts = PRODUCTS.filter((product) => + product.name.toLowerCase().includes(query.toLowerCase()) + ); + return ( +
+ + setQuery(e.target.value)} + placeholder="Filter products" + /> + +
+ ); +} + +function Cart() { + const [count, setCount] = useState(0); + return ( +
+ + +
+ ); +} + +function CartBadge({ count }) { + return Cart: {count}; +} + +function ProductList({ products }) { + return ( +
    + {products.map((product) => ( + + ))} +
+ ); +} + +function ProductRow({ product }) { + return ( +
  • + {product.name} ${product.price} +
  • + ); +} +``` + +```js src/index.js +import 'react-devtools-cdt-mcp/register'; + +import { createRoot } from 'react-dom/client'; +import './styles.css'; +import App from './App'; +import { mountToolConsole } from './ToolConsole'; + +createRoot(document.getElementById('root')).render(); +mountToolConsole(); +``` + +```js src/ToolConsole.js hidden +// A tiny stand-in for chrome-devtools-mcp. It discovers the React tool group +// the same way chrome-devtools-mcp does (the `devtoolstooldiscovery` event) +// and lets you call the tools by hand. +function discoverToolGroup() { + let toolGroup = null; + const event = new Event('devtoolstooldiscovery'); + event.respondWith = group => { + toolGroup = group; + }; + window.dispatchEvent(event); + return toolGroup; +} + +function firstUid(tools, name) { + const find = tools.find(t => t.name === 'react_find_components'); + const result = find.execute({name}); + return result.results && result.results[0] ? result.results[0].uid : 'r0'; +} + +function exampleParams(tools, toolName) { + switch (toolName) { + case 'react_get_component_tree': + return {depth: 4}; + case 'react_find_components': + return {name: 'Row'}; + case 'react_get_component_by_uid': + return {uid: firstUid(tools, 'App'), includeHooks: true}; + case 'react_get_component_by_dom_element': + return {element: '(click "Pick element", then click the page)'}; + case 'react_get_component_source': + case 'react_get_owner_stack_trace': + case 'react_get_parent_stack': + case 'react_get_owner_stack': + return {uid: firstUid(tools, 'CartBadge')}; + case 'react_start_profiling': + return {traceName: 'add-to-cart'}; + case 'react_stop_profiling': + return {}; + case 'react_get_trace_overview': + return {traceName: 'add-to-cart'}; + case 'react_get_commit_report': + return {traceName: 'add-to-cart', commitIndex: 0}; + default: + return {}; + } +} + +export function mountToolConsole() { + const toolGroup = discoverToolGroup(); + const container = document.createElement('section'); + container.className = 'tool-console'; + document.body.appendChild(container); + if (toolGroup === null) { + container.textContent = + 'No tools found. Import react-devtools-cdt-mcp/register before React.'; + return; + } + const {tools} = toolGroup; + container.innerHTML = ` +

    Tool console

    + +

    + +
    + + +
    +
    
    +  `;
    +  const select = container.querySelector('select');
    +  const description = container.querySelector('.description');
    +  const textarea = container.querySelector('textarea');
    +  const runButton = container.querySelector('.run');
    +  const pickButton = container.querySelector('.pick');
    +  const output = container.querySelector('pre');
    +  let pickedElement = null;
    +
    +  for (const tool of tools) {
    +    const option = document.createElement('option');
    +    option.value = tool.name;
    +    option.textContent = tool.name;
    +    select.appendChild(option);
    +  }
    +
    +  function selectTool() {
    +    const tool = tools.find(t => t.name === select.value);
    +    description.textContent = tool.description;
    +    textarea.value = JSON.stringify(exampleParams(tools, tool.name));
    +    pickButton.hidden = tool.name !== 'react_get_component_by_dom_element';
    +    pickedElement = null;
    +  }
    +
    +  function run() {
    +    const tool = tools.find(t => t.name === select.value);
    +    let params;
    +    try {
    +      params = JSON.parse(textarea.value || '{}');
    +    } catch (error) {
    +      output.textContent = 'Invalid JSON: ' + error.message;
    +      return;
    +    }
    +    if (tool.name === 'react_get_component_by_dom_element') {
    +      params.element = pickedElement;
    +    }
    +    const result = tool.execute(params);
    +    output.textContent = JSON.stringify(result, null, 2);
    +  }
    +
    +  pickButton.addEventListener('click', () => {
    +    output.textContent = 'Click any element in the app above...';
    +    document.addEventListener(
    +      'click',
    +      event => {
    +        if (container.contains(event.target)) {
    +          return;
    +        }
    +        event.preventDefault();
    +        event.stopPropagation();
    +        pickedElement = event.target;
    +        textarea.value = JSON.stringify({
    +          element: '<' + event.target.tagName.toLowerCase() + '>',
    +        });
    +        run();
    +      },
    +      {capture: true, once: true},
    +    );
    +  });
    +  select.addEventListener('change', selectTool);
    +  runButton.addEventListener('click', run);
    +  selectTool();
    +}
    +```
    +
    +```css src/styles.css hidden
    +header { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
    +.badge { padding: 2px 8px; border-radius: 10px; background: #087ea4; color: white; }
    +ul { padding-left: 20px; max-height: 160px; overflow: auto; }
    +.tool-console { margin-top: 20px; padding-top: 12px; border-top: 1px solid #ddd; }
    +.tool-console select, .tool-console textarea { width: 100%; font-family: monospace; }
    +.tool-console .actions { display: flex; gap: 8px; margin: 8px 0; }
    +.tool-console pre { background: #f6f7f9; padding: 8px; max-height: 300px; overflow: auto; }
    +```
    +
    +```json package.json hidden
    +{
    +  "dependencies": {
    +    "react": "latest",
    +    "react-dom": "latest",
    +    "react-scripts": "latest",
    +    "react-devtools-cdt-mcp": "0.0.1"
    +  },
    +  "scripts": {
    +    "start": "react-scripts start",
    +    "build": "react-scripts build",
    +    "test": "react-scripts test --env=jsdom",
    +    "eject": "react-scripts eject"
    +  }
    +}
    +```
    +
    +
    + + + +The tool console in this sandbox stands in for Chrome DevTools MCP so you can try the tools on this page. In your own app, you don't write any of this code: Chrome DevTools MCP discovers the tools and your agent decides which ones to call. + + + +--- + +## Reference {/*reference*/} + +### Tools {/*tools*/} + +`react-devtools-cdt-mcp` registers a tool group called `react`. Your agent calls these tools through Chrome DevTools MCP. + +* `react_get_component_tree`: Returns a snapshot of the component tree. +* `react_find_components`: Finds components by name. +* `react_get_component_by_uid`: Returns a component's props and Hooks. +* `react_get_component_by_dom_element`: Returns the React host component for a DOM element. +* `react_get_parent_stack`: Returns where a component is mounted in the tree. +* `react_get_owner_stack`: Returns the components that created a component in their JSX. +* `react_get_owner_stack_trace`: Returns the owner stack of a component as a stack trace. +* `react_get_component_source`: Returns where a component is defined. +* `react_start_profiling`: Starts recording render timing. +* `react_stop_profiling`: Stops recording render timing. +* `react_get_trace_overview`: Returns a summary of every commit in a recording. +* `react_get_commit_report`: Returns which components rendered in a commit and how long each took. + +Components are identified by short, stable uids like `"r5"`. A uid stays the same across every tool and across re-renders, but not across page reloads. + +Every tool returns a plain, serializable object. If a tool fails, it returns an object with an `error` message instead. + +--- + +### `register(target?)` {/*register*/} + +Call `register` to install the React DevTools hook and register the React tools with Chrome DevTools MCP yourself, instead of importing `react-devtools-cdt-mcp/register`. + +```js +import { register } from 'react-devtools-cdt-mcp'; + +register(); +``` + +#### Parameters {/*register-parameters*/} + +* **optional** `target`: The global object to install the hook on. Defaults to `globalThis`. + +#### Returns {/*register-returns*/} + +`register` returns an object with two properties: + +* `facade`: The installed React DevTools hook and the state the tools read from. +* `unregister`: A function that stops registering the React tools with Chrome DevTools MCP. + +#### Caveats {/*register-caveats*/} + +* Call `register` before React initializes, or React won't connect to the hook. +* Calling `register` again for the same `target` returns the existing registration. + +--- + +## Troubleshooting {/*troubleshooting*/} + +#### My agent doesn't see any React tools {/*my-agent-doesnt-see-any-react-tools*/} + +Check that [third-party developer tools](https://developer.chrome.com/blog/devtools-for-agents-3p-tools) are enabled in your Chrome DevTools MCP setup. Then check that the page selected in Chrome DevTools MCP imports `react-devtools-cdt-mcp/register`. The tools are discovered per page, when the page loads or is selected. + +#### The component tree is empty {/*the-component-tree-is-empty*/} + +`react-devtools-cdt-mcp/register` was imported after React initialized. Move the import to the very first line of your entry file, before any import that loads `react-dom`. + +#### I'm getting an error about a browser-like environment {/*im-getting-an-error-about-a-browser-like-environment*/} + +`react-devtools-cdt-mcp/register` throws if it's imported outside a browser, for example during server rendering or in tests. Import it only from client-side code, or call `register()` from the package root yourself where it's safe. + +#### Source locations and owner stacks are empty {/*source-locations-and-owner-stacks-are-empty*/} + +This data only exists in development builds of React. Make sure you're running your app's development server rather than a production build. + +#### A uid stopped working {/*a-uid-stopped-working*/} + +Uids don't survive page reloads. After a reload, get fresh uids with `react_get_component_tree` or `react_find_components`. diff --git a/src/content/reference/dev-tools/react-performance-tracks.md b/src/content/reference/dev-tools/react-performance-tracks.md index d1b7bfce9..2dae0d073 100644 --- a/src/content/reference/dev-tools/react-performance-tracks.md +++ b/src/content/reference/dev-tools/react-performance-tracks.md @@ -140,8 +140,13 @@ Scheduler は、異なる優先度を持つタスクを管理するために使 サーバリクエストトラックは、最終的に React Server Component 内で使われるすべてのプロミス (Promise) を可視化します。これには、`fetch` の呼び出しや非同期 Node.js ファイル操作などの `async` 操作が含まれます。 +<<<<<<< HEAD React は、サードパーティのコードから開始されたプロミスを、ファーストパーティコードをブロックする操作全体の継続時間を表す単一のスパンに結合しようとします。 例えば、内部的に複数回 `fetch` を呼び出す `getUser` というサードパーティライブラリのメソッドは、複数の `fetch` スパンを表示するのではなく、`getUser` という単一のスパンとして表されます。 +======= +React will try to combine Promises that are started from inside third-party code into a single span representing the duration of the entire operation blocking 1st party code. +For example, a third party library method called `getUser` that calls `fetch` internally multiple times will be represented as a single span called `getUser`, instead of showing multiple `fetch` spans. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 スパンをクリックすると、プロミスが作成された場所のスタックトレースと、利用可能な場合はプロミスが解決した値のビューが表示されます。 @@ -155,5 +160,10 @@ React は、サードパーティのコードから開始されたプロミス コンポーネントのレンダーの継続時間を示すために異なる色が使用されます。色が濃いほど、継続時間が長いことを示します。 +<<<<<<< HEAD サーバコンポーネントトラックグループには、常に "Primary" トラックが含まれます。React がサーバコンポーネントを並行してレンダーできる場合、追加の "Parallel" トラックが表示されます。 8 つを超えるサーバコンポーネントが並行してレンダーされる場合、React はさらにトラックを追加するのではなく、最後の "Parallel" トラックに関連付けます。 +======= +The Server Components track group will always contain a "Primary" track. If React is able to render Server Components concurrently, it will display additional "Parallel" tracks. +If more than 8 Server Components are rendered concurrently, React will associate them with the last "Parallel" track instead of adding more tracks. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md b/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md index bffa87a2d..44f2854dc 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md @@ -107,4 +107,8 @@ function Counter({max}) { これで、セッタはクリックに応じてのみ実行され、React はレンダーを正常に完了し、`count` が `max` を超えることはなくなります。 +<<<<<<< HEAD まれに、以前のレンダーの情報に基づいて state を調整する必要があるかもしれません。その場合は、条件付きで state を設定する[こちらのパターン](https://react.dev/reference/react/useState#storing-information-from-previous-renders)に従ってください。 +======= +In rare cases, you may need to adjust state based on information from previous renders. For those, follow [this pattern](/reference/react/useState#storing-information-from-previous-renders) of setting state conditionally. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md b/src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md index 5e29c0c39..3b526f4d2 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md @@ -79,7 +79,11 @@ function Component({user}) { } ``` +<<<<<<< HEAD 副作用によって React の state を外部の状態と同期する(またはその逆を行う)場合は、`useEffect` を使ってください。 +======= +If the side effect synchronizes React state with some external state (or vice versa), use `useEffect`: +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ```js // ✅ Good: Synchronization in useEffect diff --git a/src/content/reference/react-dom/client/createRoot.md b/src/content/reference/react-dom/client/createRoot.md index 424ac2faa..2396a8e24 100644 --- a/src/content/reference/react-dom/client/createRoot.md +++ b/src/content/reference/react-dom/client/createRoot.md @@ -90,7 +90,11 @@ React は `root` に `` を表示し、その内部の DOM の管理を * 同じルートに対して `render` を複数回呼び出すと、React は最新の JSX を反映するために必要なだけの DOM の更新を行います。React は、渡された JSX を以前にレンダーしたツリーと[「マッチング」](/learn/preserving-and-resetting-state)して、DOM のどの部分が再利用でき、どの部分を再作成する必要があるのかを決定します。同じルートに対して複数回 `render` を呼び出すことは、ルートコンポーネントで [`set` 関数](/reference/react/useState#setstate)を呼び出すことに似ており、React は不必要な DOM 更新を回避します。 +<<<<<<< HEAD * レンダーは一度始まると同期的に実行されますが、`root.render(...)` 自体は同期的ではありません。つまり、`root.render()` の後に書かれたコードが、そのレンダーで発生するエフェクト(`useLayoutEffect` や `useEffect`)よりも先に実行される場合があります。これは通常問題なく、調整が必要となることは滅多にありません。エフェクトのタイミングが重要となる稀なケースでは、[`flushSync`](https://react.dev/reference/react-dom/flushSync) で `root.render(...)` をラップすることで、初回レンダーを完全に同期的に実行できます。 +======= +* Although rendering is synchronous once it starts, `root.render(...)` is not. This means code after `root.render()` may run before any effects (`useLayoutEffect`, `useEffect`) of that specific render are fired. This is usually fine and rarely needs adjustment. In rare cases where effect timing matters, you can wrap `root.render(...)` in [`flushSync`](/reference/react-dom/flushSync) to ensure the initial render runs fully synchronously. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ```js const root = createRoot(document.getElementById('root')); @@ -379,7 +383,11 @@ const root = createRoot(container, { 1. スローされた error。 2. errorInfo オブジェクト。エラーの componentStack を含んでいる。 +<<<<<<< HEAD `onUncaughtError` と `onRecoverableError` を組み合わせて、独自のエラーレポーティングのシステムを実装できます。 +======= +Together with `onUncaughtError` and `onRecoverableError`, you can implement your own error reporting system: +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 @@ -419,7 +427,7 @@ const container = document.getElementById("root"); const root = createRoot(container, { // Keep in mind to remove these options in development to leverage // React's default handlers or implement your own overlay for development. - // The handlers are only specfied unconditionally here for demonstration purposes. + // The handlers are only specified unconditionally here for demonstration purposes. onCaughtError: onCaughtErrorProd, onRecoverableError: onRecoverableErrorProd, onUncaughtError: onUncaughtErrorProd, diff --git a/src/content/reference/react-dom/client/hydrateRoot.md b/src/content/reference/react-dom/client/hydrateRoot.md index 3dd8efb63..6756c68d4 100644 --- a/src/content/reference/react-dom/client/hydrateRoot.md +++ b/src/content/reference/react-dom/client/hydrateRoot.md @@ -124,7 +124,11 @@ React で完全に構築されたアプリには、通常、`root.unmount` の ### サーバでレンダーされた HTML のハイドレーション {/*hydrating-server-rendered-html*/} +<<<<<<< HEAD あなたのアプリの HTML が [`react-dom/server`](/reference/react-dom/client/createRoot) によって生成されている場合、クライアント上それに対する*ハイドレーション*を行う必要があります。 +======= +If your app's HTML was generated by [`react-dom/server`](/reference/react-dom/server), you need to *hydrate* it on the client. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 ```js [[1, 3, "document.getElementById('root')"], [2, 3, ""]] import { hydrateRoot } from 'react-dom/client'; @@ -449,7 +453,7 @@ const container = document.getElementById("root"); hydrateRoot(container, , { // Keep in mind to remove these options in development to leverage // React's default handlers or implement your own overlay for development. - // The handlers are only specfied unconditionally here for demonstration purposes. + // The handlers are only specified unconditionally here for demonstration purposes. onCaughtError: onCaughtErrorProd, onRecoverableError: onRecoverableErrorProd, onUncaughtError: onUncaughtErrorProd, diff --git a/src/content/reference/react-dom/components/common.md b/src/content/reference/react-dom/components/common.md index 7ade0b9eb..c7403413c 100644 --- a/src/content/reference/react-dom/components/common.md +++ b/src/content/reference/react-dom/components/common.md @@ -257,9 +257,15 @@ title: "
    などの一般的なコンポーネント" [`ref` コールバックを使用した例を見る](/learn/manipulating-the-dom-with-refs#how-to-manage-a-list-of-refs-using-a-ref-callback) +<<<<<<< HEAD `
    ` DOM ノードが画面に追加されると、React はその DOM `node` を引数として `ref` コールバックを呼び出します。`
    ` DOM ノードが削除されると、React はコールバックが返したクリーンアップ関数を呼び出します。 React は、*異なる* `ref` コールバックが渡された場合も `ref` コールバックを呼び出します。上記の例では、`(node) => { ... }` は毎回のレンダーで異なる関数です。コンポーネントが再レンダーされると、*前*の関数が `null` を引数として呼び出され、*次*の関数が DOM ノードを引数として呼び出されます。 +======= +When the `
    ` DOM node is added to the screen, React will call your `ref` callback with the DOM `node` as the argument. When that `
    ` DOM node is removed, React will call the cleanup function returned from the callback. + +React will also call your `ref` callback whenever you pass a *different* `ref` callback. In the above example, `(node) => { ... }` is a different function on every render. When your component re-renders, the cleanup function returned by the *previous* function will be called, and the *next* function will be called with the DOM node. If no cleanup function is returned, the *previous* function will be called with `null` as the argument instead. +>>>>>>> 15653c0f9b95d6c4845e614e5bcc94c7ee2128f6 #### 引数 {/*ref-callback-parameters*/} diff --git a/src/content/reference/react-dom/components/form.md b/src/content/reference/react-dom/components/form.md index 163267b64..8ba280c7e 100644 --- a/src/content/reference/react-dom/components/form.md +++ b/src/content/reference/react-dom/components/form.md @@ -38,21 +38,43 @@ title: "
    " `` は、[一般的な要素の props](/reference/react-dom/components/common#common-props) をすべてサポートしています。 +<<<<<<< HEAD [`action`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action):URL または関数。`action` として URL が渡された場合、フォームは HTML の form コンポーネントと同様に動作します。`action` として関数が渡された場合、その関数がフォームの送信を [Action prop パターン](/reference/react/useTransition#exposing-action-props-from-components)を用いてトランジション内で処理します。`action` に渡された関数は非同期でもよく、送信されたフォームの [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) を唯一の引数として呼び出されます。`action` は、`