Skip to content

Commit 2280677

Browse files
authored
Merge pull request #530 from reactjs/sync-9000e6e0
Sync with react.dev @ 9000e6e
2 parents 6d155ef + 4a7ab57 commit 2280677

30 files changed

+205
-200
lines changed

.github/workflows/discord_notify.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Discord Notify
2+
3+
on:
4+
pull_request_target:
5+
types: [ labeled ]
6+
7+
jobs:
8+
notify:
9+
if: ${{ github.event.label.name == 'React Core Team' }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Discord Webhook Action
13+
uses: tsickert/[email protected]
14+
with:
15+
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
16+
embed-author-name: ${{ github.event.pull_request.user.login }}
17+
embed-author-url: ${{ github.event.pull_request.user.html_url }}
18+
embed-author-icon-url: ${{ github.event.pull_request.user.avatar_url }}
19+
embed-title: '#${{ github.event.number }} (+${{github.event.pull_request.additions}} -${{github.event.pull_request.deletions}}): ${{ github.event.pull_request.title }}'
20+
embed-description: ${{ github.event.pull_request.body }}
21+
embed-url: ${{ github.event.pull_request.html_url }}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This repo contains the source code and documentation powering [it.reactjs.org](h
1212
### Prerequisites
1313

1414
1. Git
15-
1. Node: any 12.x version starting with v12.0.0 or greater
15+
1. Node: any version starting with v16.8.0 or greater
1616
1. Yarn: See [Yarn website for installation instructions](https://yarnpkg.com/lang/en/docs/install/)
1717
1. A fork of the repo (for any contributions)
1818
1. A clone of the [it.react.dev repo](https://github.com/reactjs/it.react.dev) on your local machine

public/images/team/lauren.jpg

949 KB
Loading

src/components/MDX/TerminalBlock.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function TerminalBlock({level = 'info', children}: TerminalBlockProps) {
7171
</div>
7272
</div>
7373
<div
74-
className="px-8 pt-4 pb-6 text-primary-dark dark:text-primary-dark font-mono text-code whitespace-pre overflow-x-scroll"
74+
className="px-8 pt-4 pb-6 text-primary-dark dark:text-primary-dark font-mono text-code whitespace-pre overflow-x-auto"
7575
translate="no"
7676
dir="ltr">
7777
<LevelText type={level} />

src/content/blog/2024/04/25/react-19-upgrade-guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ This will run the following codemods from `react-codemod`:
113113
- [`replace-string-ref`](https://github.com/reactjs/react-codemod?tab=readme-ov-file#replace-string-ref)
114114
- [`replace-act-import`](https://github.com/reactjs/react-codemod?tab=readme-ov-file#replace-act-import)
115115
- [`replace-use-form-state`](https://github.com/reactjs/react-codemod?tab=readme-ov-file#replace-use-form-state)
116-
- [`prop-types-typescript`](TODO)
116+
- [`prop-types-typescript`](https://codemod.com/registry/react-prop-types-typescript)
117117

118118
This does not include the TypeScript changes. See [TypeScript changes](#typescript-changes) below.
119119

src/content/blog/2024/12/05/react-19.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Additions since this post was originally shared with the React 19 RC in April:
1717
- **Pre-warming for suspended trees**: see [Improvements to Suspense](/blog/2024/04/25/react-19-upgrade-guide#improvements-to-suspense).
1818
- **React DOM static APIs**: see [New React DOM Static APIs](#new-react-dom-static-apis).
1919

20-
_The date for this post has been update to reflect the stable release date._
20+
_The date for this post has been updated to reflect the stable release date._
2121

2222
</Note>
2323

@@ -362,7 +362,7 @@ React 19 includes all of the React Server Components features included from the
362362

363363
#### How do I build support for Server Components? {/*how-do-i-build-support-for-server-components*/}
364364

365-
While React Server Components in React 19 are stable and will not break between major versions, the underlying APIs used to implement a React Server Components bundler or framework do not follow semver and may break between minors in React 19.x.
365+
While React Server Components in React 19 are stable and will not break between minor versions, the underlying APIs used to implement a React Server Components bundler or framework do not follow semver and may break between minors in React 19.x.
366366

367367
To support React Server Components as a bundler or framework, we recommend pinning to a specific React version, or using the Canary release. We will continue working with bundlers and frameworks to stabilize the APIs used to implement React Server Components in the future.
368368

@@ -807,4 +807,4 @@ Thanks to [Joey Arhar](https://github.com/josepharhar) for driving the design an
807807
#### How to upgrade {/*how-to-upgrade*/}
808808
See the [React 19 Upgrade Guide](/blog/2024/04/25/react-19-upgrade-guide) for step-by-step instructions and a full list of breaking and notable changes.
809809

810-
_Note: this post was originally published 04/25/2024 and has been updated to 12/05/2024 with the stable release._
810+
_Note: this post was originally published 04/25/2024 and has been updated to 12/05/2024 with the stable release._

src/content/community/conferences.md

+46-30
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,78 @@ Do you know of a local React.js conference? Add it here! (Please keep the list c
1010

1111
## Upcoming Conferences {/*upcoming-conferences*/}
1212

13-
### React Universe Conf 2024 {/*react-universe-conf-2024*/}
14-
September 5-6, 2024. Wrocław, Poland.
13+
### React Day Berlin 2024 {/*react-day-berlin-2024*/}
14+
December 13 & 16, 2024. In-person in Berlin, Germany + remote (hybrid event)
15+
16+
[Website](https://reactday.berlin/) - [Twitter](https://x.com/reactdayberlin)
17+
18+
### App.js Conf 2025 {/*appjs-conf-2025*/}
19+
May 28 - 30, 2025. In-person in Kraków, Poland + remote
20+
21+
[Website](https://appjs.co) - [Twitter](https://twitter.com/appjsconf)
22+
23+
### React Summit 2025 {/*react-summit-2025*/}
24+
June 13 - 17, 2025. In-person in Amsterdam, Netherlands + remote (hybrid event)
25+
26+
[Website](https://reactsummit.com/) - [Twitter](https://x.com/reactsummit)
27+
28+
### React Universe Conf 2025 {/*react-universe-conf-2025*/}
29+
September 2-4, 2025. Wrocław, Poland.
1530

1631
[Website](https://www.reactuniverseconf.com/) - [Twitter](https://twitter.com/react_native_eu) - [LinkedIn](https://www.linkedin.com/events/reactuniverseconf7163919537074118657/)
1732

18-
### React Alicante 2024 {/*react-alicante-2024*/}
19-
September 19-21, 2024. Alicante, Spain.
33+
## Past Conferences {/*past-conferences*/}
2034

21-
[Website](https://reactalicante.es/) - [Twitter](https://twitter.com/ReactAlicante) - [YouTube](https://www.youtube.com/channel/UCaSdUaITU1Cz6PvC97A7e0w)
35+
### React Africa 2024 {/*react-africa-2024*/}
36+
November 29, 2024. In-person in Casablanca, Morocco (hybrid event)
2237

23-
### RenderCon Kenya 2024 {/*rendercon-kenya-2024*/}
24-
October 04 - 05, 2024. Nairobi, Kenya
38+
[Website](https://react-africa.com/) - [Twitter](https://x.com/BeJS_)
2539

26-
[Website](https://rendercon.org/) - [Twitter](https://twitter.com/renderconke) - [LinkedIn](https://www.linkedin.com/company/renderconke/) - [YouTube](https://www.youtube.com/channel/UC0bCcG8gHUL4njDOpQGcMIA)
40+
### React Summit US 2024 {/*react-summit-us-2024*/}
41+
November 19 & 22, 2024. In-person in New York, USA + online (hybrid event)
2742

28-
### React India 2024 {/*react-india-2024*/}
29-
October 17 - 19, 2024. In-person in Goa, India (hybrid event) + Oct 15 2024 - remote day
43+
[Website](https://reactsummit.us/) - [Twitter](https://twitter.com/reactsummit) - [Videos](https://portal.gitnation.org/)
3044

31-
[Website](https://www.reactindia.io) - [Twitter](https://twitter.com/react_india) - [Facebook](https://www.facebook.com/ReactJSIndia) - [Youtube](https://www.youtube.com/channel/UCaFbHCBkPvVv1bWs_jwYt3w)
45+
### React Native London Conf 2024 {/*react-native-london-2024*/}
46+
November 14 & 15, 2024. In-person in London, UK
3247

33-
### React Brussels 2024 {/*react-brussels-2024*/}
34-
October 18, 2024. In-person in Brussels, Belgium (hybrid event)
48+
[Website](https://reactnativelondon.co.uk/) - [Twitter](https://x.com/RNLConf)
3549

36-
[Website](https://www.react.brussels/) - [Twitter](https://x.com/BrusselsReact)
50+
### React Advanced London 2024 {/*react-advanced-london-2024*/}
51+
October 25 & 28, 2024. In-person in London, UK + online (hybrid event)
52+
53+
[Website](https://reactadvanced.com/) - [Twitter](https://x.com/reactadvanced)
3754

3855
### reactjsday 2024 {/*reactjsday-2024*/}
3956
October 25, 2024. In-person in Verona, Italy + online (hybrid event)
4057

4158
[Website](https://2024.reactjsday.it/) - [Twitter](https://x.com/reactjsday) - [Facebook](https://www.facebook.com/GrUSP/) - [YouTube](https://www.youtube.com/c/grusp)
4259

43-
### React Advanced London 2024 {/*react-advanced-london-2024*/}
44-
October 25 & 28, 2024. In-person in London, UK + online (hybrid event)
60+
### React Brussels 2024 {/*react-brussels-2024*/}
61+
October 18, 2024. In-person in Brussels, Belgium (hybrid event)
4562

46-
[Website](https://reactadvanced.com/) - [Twitter](https://x.com/reactadvanced)
63+
[Website](https://www.react.brussels/) - [Twitter](https://x.com/BrusselsReact)
4764

48-
### React Native London Conf 2024 {/*react-native-london-2024*/}
49-
November 14 & 15, 2024. In-person in London, UK
65+
### React India 2024 {/*react-india-2024*/}
66+
October 17 - 19, 2024. In-person in Goa, India (hybrid event) + Oct 15 2024 - remote day
5067

51-
[Website](https://reactnativelondon.co.uk/) - [Twitter](https://x.com/RNLConf)
68+
[Website](https://www.reactindia.io) - [Twitter](https://twitter.com/react_india) - [Facebook](https://www.facebook.com/ReactJSIndia) - [Youtube](https://www.youtube.com/channel/UCaFbHCBkPvVv1bWs_jwYt3w)
5269

53-
### React Summit US 2024 {/*react-summit-us-2024*/}
54-
November 19 & 22, 2024. In-person in New York, USA + online (hybrid event)
70+
### RenderCon Kenya 2024 {/*rendercon-kenya-2024*/}
71+
October 04 - 05, 2024. Nairobi, Kenya
5572

56-
[Website](https://reactsummit.us/) - [Twitter](https://twitter.com/reactsummit) - [Videos](https://portal.gitnation.org/)
73+
[Website](https://rendercon.org/) - [Twitter](https://twitter.com/renderconke) - [LinkedIn](https://www.linkedin.com/company/renderconke/) - [YouTube](https://www.youtube.com/channel/UC0bCcG8gHUL4njDOpQGcMIA)
5774

58-
### React Africa 2024 {/*react-africa-2024*/}
59-
November 29, 2024. In-person in Casablanca, Morocco (hybrid event)
75+
### React Alicante 2024 {/*react-alicante-2024*/}
76+
September 19-21, 2024. Alicante, Spain.
6077

61-
[Website](https://react-africa.com/) - [Twitter](https://x.com/BeJS_)
78+
[Website](https://reactalicante.es/) - [Twitter](https://twitter.com/ReactAlicante) - [YouTube](https://www.youtube.com/channel/UCaSdUaITU1Cz6PvC97A7e0w)
6279

63-
### React Day Berlin 2024 {/*react-day-berlin-2024*/}
64-
December 13 & 16, 2024. In-person in Berlin, Germany + remote (hybrid event)
80+
### React Universe Conf 2024 {/*react-universe-conf-2024*/}
81+
September 5-6, 2024. Wrocław, Poland.
6582

66-
[Website](https://reactday.berlin/) - [Twitter](https://x.com/reactdayberlin)
83+
[Website](https://www.reactuniverseconf.com/) - [Twitter](https://twitter.com/react_native_eu) - [LinkedIn](https://www.linkedin.com/events/reactuniverseconf7163919537074118657/)
6784

68-
## Past Conferences {/*past-conferences*/}
6985

7086
### React Rally 2024 🐙 {/*react-rally-2024*/}
7187
August 12-13, 2024. Park City, UT, USA

src/content/community/team.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Current members of the React team are listed in alphabetical order below.
4343
</TeamMember>
4444

4545
<TeamMember name="Lauren Tan" permalink="lauren-tan" photo="/images/team/lauren.jpg" github="poteto" twitter="potetotes" threads="potetotes" bsky="no.lol" title="Engineer at Meta">
46-
Lauren's programming career peaked when she first discovered the `<marquee>` tag. She’s been chasing that high ever since. She studied Finance instead of CS in college, so she learned to code using Excel instead of Java. Lauren enjoys dropping cheeky memes in chat, playing video games with her partner, and petting her dog Zelda.
46+
Lauren's programming career peaked when she first discovered the `<marquee>` tag. She’s been chasing that high ever since. She studied Finance instead of CS in college, so she learned to code using Excel. Lauren enjoys dropping cheeky memes in chat, playing video games with her partner, learning Korean, and petting her dog Zelda.
4747
</TeamMember>
4848

4949
<TeamMember name="Luna Wei" permalink="luna-wei" photo="/images/team/luna-wei.jpg" github="lunaleaps" twitter="lunaleaps" threads="lunaleaps" title="Engineer at Meta">

src/content/learn/add-react-to-an-existing-project.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Supponiamo tu abbia una web app esistente a `example.com` costruita con un'altra
2121
Ecco come ti consigliamo di impostarla:
2222

2323
1. **Crea la parte React della tua app** utilizzando uno dei [framework basati su React](/learn/start-a-new-react-project).
24-
2. **Specifica `/some-app` come *percorso di base*** nella configurazione del tuo framework (ecco come: [Next.js](https://nextjs.org/docs/api-reference/next.config.js/basepath), [Gatsby](https://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/path-prefix/)).
24+
2. **Specifica `/some-app` come *percorso di base*** nella configurazione del tuo framework (ecco come: [Next.js](https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath), [Gatsby](https://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/path-prefix/)).
2525
3. **Configura il tuo server o un proxy** in modo che tutte le richieste in `/some-app/` siano gestite dalla tua app React.
2626

2727
Ciò garantisce che la parte React della tua app possa [trarre vantaggio dalle best practices](/learn/start-a-new-react-project#can-i-use-react-without-a-framework) integrate in tali framework.

src/content/learn/manipulating-the-dom-with-refs.md

+24-68
Original file line numberDiff line numberDiff line change
@@ -343,75 +343,39 @@ Read more about [how this helps find bugs](/reference/react/StrictMode#fixing-bu
343343

344344
## Accessing another component's DOM nodes {/*accessing-another-components-dom-nodes*/}
345345

346-
When you put a ref on a built-in component that outputs a browser element like `<input />`, React will set that ref's `current` property to the corresponding DOM node (such as the actual `<input />` in the browser).
346+
<Pitfall>
347+
Refs are an escape hatch. Manually manipulating _another_ component's DOM nodes can make your code fragile.
348+
</Pitfall>
347349

348-
However, if you try to put a ref on **your own** component, like `<MyInput />`, by default you will get `null`. Here is an example demonstrating it. Notice how clicking the button **does not** focus the input:
350+
You can pass refs from parent component to child components [just like any other prop](/learn/passing-props-to-a-component).
349351

350-
<Sandpack>
351-
352-
```js
352+
```js {3-4,9}
353353
import { useRef } from 'react';
354354

355-
function MyInput(props) {
356-
return <input {...props} />;
355+
function MyInput({ ref }) {
356+
return <input ref={ref} />;
357357
}
358358

359-
export default function MyForm() {
359+
function MyForm() {
360360
const inputRef = useRef(null);
361-
362-
function handleClick() {
363-
inputRef.current.focus();
364-
}
365-
366-
return (
367-
<>
368-
<MyInput ref={inputRef} />
369-
<button onClick={handleClick}>
370-
Focus the input
371-
</button>
372-
</>
373-
);
361+
return <MyInput ref={inputRef} />
374362
}
375363
```
376364

377-
</Sandpack>
378-
379-
To help you notice the issue, React also prints an error to the console:
380-
381-
<ConsoleBlock level="error">
382-
383-
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
384-
385-
</ConsoleBlock>
386-
387-
This happens because by default React does not let a component access the DOM nodes of other components. Not even for its own children! This is intentional. Refs are an escape hatch that should be used sparingly. Manually manipulating _another_ component's DOM nodes makes your code even more fragile.
388-
389-
Instead, components that _want_ to expose their DOM nodes have to **opt in** to that behavior. A component can specify that it "forwards" its ref to one of its children. Here's how `MyInput` can use the `forwardRef` API:
390-
391-
```js
392-
const MyInput = forwardRef((props, ref) => {
393-
return <input {...props} ref={ref} />;
394-
});
395-
```
396-
397-
This is how it works:
398-
399-
1. `<MyInput ref={inputRef} />` tells React to put the corresponding DOM node into `inputRef.current`. However, it's up to the `MyInput` component to opt into that--by default, it doesn't.
400-
2. The `MyInput` component is declared using `forwardRef`. **This opts it into receiving the `inputRef` from above as the second `ref` argument** which is declared after `props`.
401-
3. `MyInput` itself passes the `ref` it received to the `<input>` inside of it.
365+
In the above example, a ref is created in the parent component, `MyForm`, and is passed to the child component, `MyInput`. `MyInput` then passes the ref to `<input>`. Because `<input>` is a [built-in component](/reference/react-dom/components/common) React sets the `.current` property of the ref to the `<input>` DOM element.
402366

403-
Now clicking the button to focus the input works:
367+
The `inputRef` created in `MyForm` now points to the `<input>` DOM element returned by `MyInput`. A click handler created in `MyForm` can access `inputRef` and call `focus()` to set the focus on `<input>`.
404368

405369
<Sandpack>
406370

407371
```js
408-
import { forwardRef, useRef } from 'react';
372+
import { useRef } from 'react';
409373

410-
const MyInput = forwardRef((props, ref) => {
411-
return <input {...props} ref={ref} />;
412-
});
374+
function MyInput({ ref }) {
375+
return <input ref={ref} />;
376+
}
413377

414-
export default function Form() {
378+
export default function MyForm() {
415379
const inputRef = useRef(null);
416380

417381
function handleClick() {
@@ -431,33 +395,27 @@ export default function Form() {
431395

432396
</Sandpack>
433397

434-
In design systems, it is a common pattern for low-level components like buttons, inputs, and so on, to forward their refs to their DOM nodes. On the other hand, high-level components like forms, lists, or page sections usually won't expose their DOM nodes to avoid accidental dependencies on the DOM structure.
435-
436398
<DeepDive>
437399

438400
#### Exposing a subset of the API with an imperative handle {/*exposing-a-subset-of-the-api-with-an-imperative-handle*/}
439401

440-
In the above example, `MyInput` exposes the original DOM input element. This lets the parent component call `focus()` on it. However, this also lets the parent component do something else--for example, change its CSS styles. In uncommon cases, you may want to restrict the exposed functionality. You can do that with `useImperativeHandle`:
402+
In the above example, the ref passed to `MyInput` is passed on to the original DOM input element. This lets the parent component call `focus()` on it. However, this also lets the parent component do something else--for example, change its CSS styles. In uncommon cases, you may want to restrict the exposed functionality. You can do that with [`useImperativeHandle`](/reference/react/useImperativeHandle):
441403

442404
<Sandpack>
443405

444406
```js
445-
import {
446-
forwardRef,
447-
useRef,
448-
useImperativeHandle
449-
} from 'react';
407+
import { useRef, useImperativeHandle } from "react";
450408

451-
const MyInput = forwardRef((props, ref) => {
409+
function MyInput({ ref }) {
452410
const realInputRef = useRef(null);
453411
useImperativeHandle(ref, () => ({
454412
// Only expose focus and nothing else
455413
focus() {
456414
realInputRef.current.focus();
457415
},
458416
}));
459-
return <input {...props} ref={realInputRef} />;
460-
});
417+
return <input ref={realInputRef} />;
418+
};
461419

462420
export default function Form() {
463421
const inputRef = useRef(null);
@@ -469,17 +427,15 @@ export default function Form() {
469427
return (
470428
<>
471429
<MyInput ref={inputRef} />
472-
<button onClick={handleClick}>
473-
Focus the input
474-
</button>
430+
<button onClick={handleClick}>Focus the input</button>
475431
</>
476432
);
477433
}
478434
```
479435

480436
</Sandpack>
481437

482-
Here, `realInputRef` inside `MyInput` holds the actual input DOM node. However, `useImperativeHandle` instructs React to provide your own special object as the value of a ref to the parent component. So `inputRef.current` inside the `Form` component will only have the `focus` method. In this case, the ref "handle" is not the DOM node, but the custom object you create inside `useImperativeHandle` call.
438+
Here, `realInputRef` inside `MyInput` holds the actual input DOM node. However, [`useImperativeHandle`](/reference/react/useImperativeHandle) instructs React to provide your own special object as the value of a ref to the parent component. So `inputRef.current` inside the `Form` component will only have the `focus` method. In this case, the ref "handle" is not the DOM node, but the custom object you create inside [`useImperativeHandle`](/reference/react/useImperativeHandle) call.
483439

484440
</DeepDive>
485441

@@ -591,7 +547,7 @@ export default function TodoList() {
591547
const newTodo = { id: nextId++, text: text };
592548
flushSync(() => {
593549
setText('');
594-
setTodos([ ...todos, newTodo]);
550+
setTodos([ ...todos, newTodo]);
595551
});
596552
listRef.current.lastChild.scrollIntoView({
597553
behavior: 'smooth',

0 commit comments

Comments
 (0)