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 81a04601c..ef43b2c8f 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 ffe1b2783..a6c2a71d1 100644 --- a/README.md +++ b/README.md @@ -7,19 +7,22 @@ This repo contains the source code and documentation powering [it.reactjs.org](h - [Glossary](GLOSSARY.md) - [Style Guide](STYLE_GUIDE.md) +React is a project of the [React Foundation](https://react.foundation/), hosted by the [Linux Foundation](https://www.linuxfoundation.org/). + ## 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 [it.react.dev repo](https://github.com/reactjs/it.react.dev) on your local machine ### Installation 1. `cd it.react.dev` to go into the project root +2. `git remote add my-fork-name https://github.com/YOUR_USERNAME/it.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 @@ -44,8 +47,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 @@ -62,7 +65,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. diff --git a/package.json b/package.json index 20af6969d..6ca0c52d1 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,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 407c1ef08..44e91f7f6 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.
Di Più Blog React Native - + Privacy - + Termini + + 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 4f1af129a..73ab51382 100644 --- a/src/content/blog/2023/03/16/introducing-react-dev.md +++ b/src/content/blog/2023/03/16/introducing-react-dev.md @@ -49,7 +49,7 @@ Quando abbiamo rilasciato React Hooks nel 2018, la documentazione sugli Hooks pr **La nuova documentazione insegna React con gli Hooks fin dall'inizio.** La documentazione è divisa in due sezioni principali: * **[Impara React](/learn)** è un corso autogestito che insegna React da zero. -* **[API Reference](/reference)** fornisce i dettagli e gli esempi d'uso per ogni API React. +* **[API Reference](/reference/react)** fornisce i dettagli e gli esempi d'uso per ogni API React. Vediamo più da vicino cosa trovi in ciascuna sezione. @@ -469,7 +469,7 @@ Nell'[API Reference](/reference/react), ogni API React ha ora una pagina dedicat - Hooks integrati come [`useState`](/reference/react/useState). - Componenti integrati come [``](/reference/react/Suspense). - Componenti browser integrati come [``](/reference/react-dom/components/input). -- API orientate ai framework come [`renderToPipeableStream`](/reference/react-dom/server/renderToReadableStream). +- API orientate ai framework come [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream). - Altre API React come [`memo`](/reference/react/memo). Noterai che ogni pagina API è divisa in almeno due segmenti: *Reference* e *Usage*. @@ -614,7 +614,7 @@ button { display: block; margin-top: 10px; } -Alcune pagine API includono anche [Troubleshooting](/reference/react/useEffect#troubleshooting) (per problemi comuni) e [Alternatives](/reference/react-dom/findDOMNode#alternatives) (per API deprecate). +Alcune pagine API includono anche [Troubleshooting](/reference/react/useEffect#troubleshooting) (per problemi comuni) e [Alternatives](https://18.react.dev/reference/react-dom/findDOMNode#alternatives) (per API deprecate). Speriamo che questo approccio renda l'API reference utile non solo per cercare un argomento, ma per vedere tutte le cose diverse che puoi fare con una data API — e come si collega alle altre. 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 8f49d8f4d..cdf6c2839 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 @@ -646,7 +646,7 @@ const ref = useRef(null); ref.current = 1; ``` -`MutableRef` è ora deprecato in favore di un unico tipo `RefObject` che `useRef` restituirà sempre: +`MutableRefObject` è ora deprecato in favore di un unico tipo `RefObject` che `useRef` restituirà sempre: ```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 115eccc58..8df0b5bed 100644 --- a/src/content/blog/2024/12/05/react-19.md +++ b/src/content/blog/2024/12/05/react-19.md @@ -397,7 +397,7 @@ Per maggiori informazioni, consulta la documentazione delle [Directives](/refere Le Server Actions possono essere create in Server Components e passate come props a Client Components, oppure possono essere importate e usate in Client Components. -Per approfondire, consulta la documentazione delle [React Server Actions](/reference/rsc/server-actions). +Per approfondire, consulta la documentazione delle [React Server Actions](/reference/rsc/server-functions). ## Miglioramenti in React 19 {/*improvements-in-react-19*/} 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 fd2c0a120..1139e4286 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 @@ -81,7 +81,7 @@ Divulgazioni aggiuntive possono essere frustranti, ma in genere sono segno di un ### Framework e bundler interessati {/*affected-frameworks-and-bundlers*/} -Alcuni framework e bundler React dipendevano, avevano peer dependency o includevano i pacchetti React vulnerabili. I seguenti framework e bundler React sono interessati: [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) e [rwsdk](https://www.npmjs.com/package/rwsdk). +Alcuni framework e bundler React dipendevano, avevano peer dependency o includevano i pacchetti React vulnerabili. I seguenti framework e bundler React sono interessati: [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) e [rwsdk](https://www.npmjs.com/package/rwsdk). Consulta [le istruzioni nel post precedente](/blog/2025/12/03/critical-security-vulnerability-in-react-server-components#update-instructions) per i passaggi di aggiornamento. diff --git a/src/content/community/conferences.md b/src/content/community/conferences.md index b7e106c45..e5bfdf1ee 100644 --- a/src/content/community/conferences.md +++ b/src/content/community/conferences.md @@ -17,26 +17,6 @@ Conosci una conferenza React.js locale? Aggiungila qui! (Mantieni l'elenco in or ## Prossime conferenze {/*upcoming-conferences*/} -### ZurichJS Conf 2026 {/*zurichjs-conf-2026*/} -September 10-11, 2026. In presenza a Zurich, Switzerland - -[Sito web](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 presenza a Alicante - -[Sito web](https://reactalicante.es//) - [Twitter](https://x.com/ReactAlicante) - -### CityJS Athens 2026 {/*cityjs-athens-2026*/} -October 21-23, 2026. In presenza a Athens - -[Sito web](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) @@ -52,6 +32,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 presenza a Tokyo, Japan + +[Sito web](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) @@ -60,16 +45,60 @@ May 21 & 25, 2027. In-person in Amsterdam, Netherlands + online (hybrid event) ## Conferenze passate {/*past-conferences*/} +### React India 2026 {/*react-india-2026*/} +October 29-31, 2026. In presenza a Goa, India -### React Conf Japan 2027 {/*react-conf-japan-2027*/} -April 24, 2027. In presenza a Tokyo, Japan +[Sito web](https://www.reactindia.io/) - [Twitter](https://x.com/react_india) -[Sito web](https://reactconf.jp/) - [Twitter](https://x.com/reactconfjp) +### React Advanced London 2026 {/*react-advanced-london-2026*/} +October 23 & 26, 2026. In presenza a London, UK + online (evento ibrido) + +[Sito web](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 presenza a Athens + +[Sito web](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 presenza a Alicante + +[Sito web](https://reactalicante.es//) - [Twitter](https://x.com/ReactAlicante) + +### React Native Connection 2026 {/*react-native-connection-2026*/} +September 24, 2026. In presenza a Paris, France + +[Sito web](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 presenza a Zurich, Switzerland + +[Sito web](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 presenza a Atlanta, GA, USA + +[Sito web](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 presenza a Amsterdam, Netherlands + online (evento ibrido) + +[Sito web](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 presenza a Oslo, Norway + +[Sito web](https://reactnorway.com/) - [Twitter](https://x.com/ReactNorway) + +### React Miami 2026 {/*react-miami-2026*/} +April 23-24, 2026. In presenza a Miami, FL, USA + +[Sito web](https://reactmiami.com/) - [Twitter](https://x.com/ReactMiamiConf) ### CityJS London 2026 {/*cityjs-london-2026*/} April 14-17, 2026. In presenza a London -[Sito web](https://india.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) +[Sito web](https://london.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) ### React Paris 2026 {/*react-paris-2026*/} @@ -86,7 +115,7 @@ February 12-13, 2026. In presenza a New Delhi, India ### CityJS Singapore 2026 {/*cityjs-singapore-2026*/} February 4-6, 2026. In presenza a Singapore -[Sito web](https://india.cityjsconf.org/) - [Twitter](https://x.com/cityjsconf) - [Bluesky](https://bsky.app/profile/cityjsconf.bsky.social) +[Sito web](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 presenza a London, UK + remoto (evento ibrido) diff --git a/src/content/learn/index.md b/src/content/learn/index.md index e5cd4b0ee..aaac28350 100644 --- a/src/content/learn/index.md +++ b/src/content/learn/index.md @@ -336,7 +336,7 @@ function MyButton() { } ``` -React chiamerà di nuovo la tua funzione componente. Questa volta, `count` sarà `1`. Poi sarà `2`. E così via. +Chiamare `setCount` dice a React di chiamare di nuovo la funzione del tuo componente. Questo si chiama *ri-renderizzazione*. Questa volta, `count` sarà `1`. Poi sarà `2`. E così via. Se esegui il rendering dello stesso componente più volte, ognuno avrà il proprio state. Fai clic su ogni pulsante separatamente: diff --git a/src/content/learn/lifecycle-of-reactive-effects.md b/src/content/learn/lifecycle-of-reactive-effects.md index 47405f343..c010a153e 100644 --- a/src/content/learn/lifecycle-of-reactive-effects.md +++ b/src/content/learn/lifecycle-of-reactive-effects.md @@ -1382,7 +1382,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(() => { @@ -1480,7 +1480,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(() => { @@ -1568,7 +1568,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/react-compiler/introduction.md b/src/content/learn/react-compiler/introduction.md index ff5d6eae4..2b6b26d38 100644 --- a/src/content/learn/react-compiler/introduction.md +++ b/src/content/learn/react-compiler/introduction.md @@ -144,7 +144,7 @@ However, if `expensivelyProcessAReallyLargeArrayOfObjects` is truly an expensive - React Compiler only memoizes React components and hooks, not every function - React Compiler's memoization is not shared across multiple components or hooks -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. +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. ## Should I try out the compiler? {/*should-i-try-out-the-compiler*/} diff --git a/src/content/learn/setup.md b/src/content/learn/setup.md index 2c46ee148..b93155cc1 100644 --- a/src/content/learn/setup.md +++ b/src/content/learn/setup.md @@ -17,7 +17,7 @@ TypeScript is a popular way to add type definitions to JavaScript codebases. [Le ## React Developer Tools {/*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). +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). ## React Compiler {/*react-compiler*/} diff --git a/src/content/learn/synchronizing-with-effects.md b/src/content/learn/synchronizing-with-effects.md index 294cdc518..75021148e 100644 --- a/src/content/learn/synchronizing-with-effects.md +++ b/src/content/learn/synchronizing-with-effects.md @@ -740,7 +740,7 @@ Scrivere chiamate `fetch` all'interno degli Effetti è un [modo popolare per rec Questo elenco di svantaggi non è specifico di React. Si applica al recupero dati al mount con qualsiasi libreria. Come per il routing, il recupero dati non è banale da fare bene, quindi consigliamo i seguenti approcci: - **Se usi un [framework](/learn/creating-a-react-app#full-stack-frameworks), usa il suo meccanismo di recupero dati integrato.** I framework React moderni hanno meccanismi di recupero dati integrati che sono efficienti e non soffrono dei problemi sopra. -- **Altrimenti, considera di usare o costruire una cache client-side.** Soluzioni open source popolari includono [TanStack Query](https://tanstack.com/query/latest), [useSWR](https://swr.vercel.app/) e [React Router 6.4+.](https://beta.reactrouter.com/en/main/start/overview) Puoi costruire anche la tua soluzione, nel qual caso useresti gli Effetti sotto il cofano, ma aggiungeresti logica per deduplicare le richieste, mettere in cache le risposte ed evitare network waterfall (precaricando i dati o spostando i requisiti di dati alle route). +- **Altrimenti, considera di usare o costruire una cache client-side.** Soluzioni open source popolari includono [TanStack Query](https://tanstack.com/query/latest), [useSWR](https://swr.vercel.app/) e [React Router](https://reactrouter.com/). Puoi costruire anche la tua soluzione, nel qual caso useresti gli Effetti sotto il cofano, ma aggiungeresti logica per deduplicare le richieste, mettere in cache le risposte ed evitare network waterfall (precaricando i dati o spostando i requisiti di dati alle route). Puoi continuare a recuperare dati direttamente negli Effetti se nessuno di questi approcci ti soddisfa. diff --git a/src/content/learn/tutorial-tic-tac-toe.md b/src/content/learn/tutorial-tic-tac-toe.md index 4c5188467..77f007066 100644 --- a/src/content/learn/tutorial-tic-tac-toe.md +++ b/src/content/learn/tutorial-tic-tac-toe.md @@ -1138,7 +1138,7 @@ JavaScript supporta le [closures](https://developer.mozilla.org/en-US/docs/Web/J -Ora puoi aggiungere X al tabellone... ma solo al quadrato in alto a sinistra. La tua funzione `handleClick` è hardcoded per aggiornare l'indice del quadrato in alto a sinistra (`0`). Aggiorniamo `handleClick` per poter aggiornare qualsiasi quadrato. Aggiungi un argomento `i` alla funzione `handleClick` che accetta l'indice del quadrato da aggiornare: +Ora puoi aggiungere X al tabellone... ma solo al quadrato in alto a sinistra. La tua funzione `handleClick` è hardcoded per aggiornare l'indice del quadrato in alto a sinistra (`0`). Aggiorniamo `handleClick` per poter aggiornare qualsiasi quadrato. Aggiungi un parametro `i` alla funzione `handleClick` che accetta l'indice del quadrato da aggiornare: ```js {4,6} export default function Board() { diff --git a/src/content/learn/typescript.md b/src/content/learn/typescript.md index 2e6f7edc5..739efe366 100644 --- a/src/content/learn/typescript.md +++ b/src/content/learn/typescript.md @@ -335,7 +335,7 @@ function MyComponent() { -The [`useMemo`](/reference/react/useMemo) Hooks will create/re-access a memorized 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. +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. ```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 afc38cd33..497eb48de 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,7 @@ The root node in a React render tree is the [root component](/learn/importing-an #### Where are the HTML tags in the render tree? {/*where-are-the-html-elements-in-the-render-tree*/} -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). +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). React, as a UI framework, is platform agnostic. On react.dev, we showcase examples that render to the web, which uses HTML markup as its UI primitives. But a React app could just as likely render to a mobile or desktop platform, which may use different UI primitives like [UIView](https://developer.apple.com/documentation/uikit/uiview) or [FrameworkElement](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-7.0). 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 d4757b9ec..1c10823d3 100644 --- a/src/content/reference/dev-tools/react-performance-tracks.md +++ b/src/content/reference/dev-tools/react-performance-tracks.md @@ -140,7 +140,7 @@ In development builds, when you click on a component render entry, you can inspe The Server Requests track visualized all Promises that eventually end up in a React Server Component. This includes any `async` operations like calling `fetch` or async Node.js file operations. -React will try to combine Promises that are started from inside third-party code into a single span representing the the duration of the entire operation blocking 1st party code. +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. Clicking on spans will show you a stack trace of where the Promise was created as well as a view of the value that the Promise resolved to, if available. @@ -155,5 +155,5 @@ If you await a Promise, React will display duration of that Promise. To see all Different colors are used to indicate the duration of the component render. The darker the color, the longer the duration. -The Server Components track group will always contain a "Primary" track. If React is able to render Server Components concurrently, it will display addititional "Parallel" tracks. +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. 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 7517d5f92..87262949d 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,4 @@ function Counter({max}) { Now the setter only runs in response to the click, React finishes the render normally, and `count` never crosses `max`. -In rare cases, you may need to adjust state based on information from previous renders. For those, follow [this pattern](https://react.dev/reference/react/useState#storing-information-from-previous-renders) of setting state conditionally. +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. 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 a5a77e5f6..56810c359 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,7 @@ function Component({user}) { } ``` -If the side effect sychronizes React state with some external state (or vice versa), use `useEffect`: +If the side effect synchronizes React state with some external state (or vice versa), use `useEffect`: ```js // ✅ Good: Synchronization in useEffect diff --git a/src/content/reference/react-dom/client/hydrateRoot.md b/src/content/reference/react-dom/client/hydrateRoot.md index d3eb68179..eb14f4317 100644 --- a/src/content/reference/react-dom/client/hydrateRoot.md +++ b/src/content/reference/react-dom/client/hydrateRoot.md @@ -131,7 +131,7 @@ Chiamare `root.unmount` smonterà tutti i componenti nella root e "scollegherà" ### Idratare HTML renderizzato lato server {/*hydrating-server-rendered-html*/} -Se l'HTML della tua app è stato generato da [`react-dom/server`](/reference/react-dom/client/createRoot), devi *idratarlo* sul client. +Se l'HTML della tua app è stato generato da [`react-dom/server`](/reference/react-dom/server), devi *idratarlo* sul client. ```js [[1, 3, "document.getElementById('root')"], [2, 3, ""]] import { hydrateRoot } from 'react-dom/client'; diff --git a/src/content/reference/react-dom/components/common.md b/src/content/reference/react-dom/components/common.md index 3f141ba77..d75c572dd 100644 --- a/src/content/reference/react-dom/components/common.md +++ b/src/content/reference/react-dom/components/common.md @@ -266,7 +266,7 @@ Invece di un oggetto ref (come quello restituito da [`useRef`](/reference/react/ Quando il nodo DOM `
    ` viene aggiunto allo schermo, React chiamerà la tua callback `ref` con il `node` DOM come argomento. Quando quel nodo DOM `
    ` viene rimosso, React chiamerà la funzione di cleanup restituita dalla callback. -React chiamerà anche la tua callback `ref` ogni volta che passi una callback `ref` *diversa*. Nell'esempio sopra, `(node) => { ... }` è una funzione diversa a ogni renderizzazione. Quando il tuo componente viene ri-renderizzato, la funzione *precedente* verrà chiamata con `null` come argomento, e la funzione *successiva* verrà chiamata con il nodo DOM. +React chiamerà anche la tua callback `ref` ogni volta che passi una callback `ref` *diversa*. Nell'esempio sopra, `(node) => { ... }` è una funzione diversa a ogni renderizzazione. Quando il tuo componente viene ri-renderizzato, verrà chiamata la funzione di cleanup restituita dalla funzione *precedente*, e la funzione *successiva* verrà chiamata con il nodo DOM. Se non viene restituita alcuna funzione di cleanup, la funzione *precedente* verrà invece chiamata con `null` come argomento. #### Parameters {/*ref-callback-parameters*/} diff --git a/src/content/reference/react-dom/components/form.md b/src/content/reference/react-dom/components/form.md index 10e9c6794..100d60f6d 100644 --- a/src/content/reference/react-dom/components/form.md +++ b/src/content/reference/react-dom/components/form.md @@ -38,21 +38,27 @@ To create interactive controls for submitting information, render the [built-in `
    ` supports all [common element props.](/reference/react-dom/components/common#common-props) -[`action`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action): a URL or function. When a URL is passed to `action` the form will behave like the HTML form component. When a function is passed to `action` the function will handle the form submission in a Transition following [the Action prop pattern](/reference/react/useTransition#exposing-action-props-from-components). The function passed to `action` may be async and will be called with a single argument containing the [form data](https://developer.mozilla.org/en-US/docs/Web/API/FormData) of the submitted form. The `action` prop can be overridden by a `formAction` attribute on a `