Skip to content

Commit 4c2847a

Browse files
merging all conflicts
2 parents aff37f8 + 46a54e0 commit 4c2847a

11 files changed

Lines changed: 122 additions & 49 deletions

File tree

‎.github/ISSUE_TEMPLATE/config.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ contact_links:
33
url: https://github.com/react/react/issues/new/choose
44
about: This issue tracker is not for bugs in React. Please file React issues here.
55
- name: 🤔 Questions and Help
6-
url: https://reactjs.org/community/support.html
6+
url: https://react.dev/community
77
about: This issue tracker is not for support questions. Please refer to the React community's help and discussion forums.

‎.github/workflows/analyze.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ jobs:
1818
- name: Set up node
1919
uses: actions/setup-node@v4
2020
with:
21-
node-version: '20.x'
21+
node-version: '24.x'
2222
cache: yarn
2323
cache-dependency-path: yarn.lock
2424

2525
- name: Restore cached node_modules
2626
uses: actions/cache@v4
2727
with:
2828
path: '**/node_modules'
29-
key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
29+
key: node_modules-24-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
3030

3131
- name: Install deps
3232
run: yarn install --frozen-lockfile

‎.github/workflows/site_lint.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ jobs:
1313
lint:
1414
runs-on: ubuntu-latest
1515

16-
name: Lint on node 20.x and ubuntu-latest
16+
name: Lint on node 24.x and ubuntu-latest
1717

1818
steps:
1919
- uses: actions/checkout@v4
20-
- name: Use Node.js 20.x
20+
- name: Use Node.js 24.x
2121
uses: actions/setup-node@v4
2222
with:
23-
node-version: 20.x
23+
node-version: 24.x
2424
cache: yarn
2525
cache-dependency-path: yarn.lock
2626

2727
- name: Restore cached node_modules
2828
uses: actions/cache@v4
2929
with:
3030
path: '**/node_modules'
31-
key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
31+
key: node_modules-24-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
3232

3333
- name: Install deps
3434
run: yarn install --frozen-lockfile

‎CLAUDE.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code when working with this repository.
44

55
## Project Overview
66

7-
This is the React documentation website (react.dev), built with Next.js 15.1.11 and React 19. Documentation is written in MDX format.
7+
This is the React documentation website (react.dev), built with Next.js 15.1.12 and React 19. Documentation is written in MDX format.
88

99
## Development Commands
1010

@@ -47,6 +47,6 @@ When editing files in `src/content/`, the appropriate skill will be auto-suggest
4747
For MDX components (DeepDive, Pitfall, Note, etc.), invoke `/docs-components`.
4848
For Sandpack code examples, invoke `/docs-sandpack`.
4949

50-
See `.claude/docs/react-docs-patterns.md` for comprehensive style guidelines.
50+
See `.claude/skills/` for comprehensive style guidelines.
5151

5252
Prettier is used for formatting (config in `.prettierrc`).

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,9 @@ Ignore this if you're specifically describing `createElement`.
3838

3939
Ignore this if you're specifically writing about ES5.
4040

41-
#### Don't use ES6 features when equivalent ES5 features have no downsides.
41+
#### Prefer readable syntax.
4242

43-
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.
44-
45-
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.
46-
47-
#### Don't use features that aren't standardized yet.
48-
49-
For example, **don't** write this:
50-
51-
```js
52-
class MyComponent extends React.Component {
53-
state = {value: ''};
54-
handleChange = (e) => {
55-
this.setState({value: e.target.value});
56-
};
57-
}
58-
```
59-
60-
Instead, **do** write this:
61-
62-
```js
63-
class MyComponent extends React.Component {
64-
constructor(props) {
65-
super(props);
66-
this.handleChange = this.handleChange.bind(this);
67-
this.state = {value: ''};
68-
}
69-
handleChange(e) {
70-
this.setState({value: e.target.value});
71-
}
72-
}
73-
```
74-
75-
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.
43+
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.
7644

7745
### Style
7846

‎README.md‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ This repo contains the source code and documentation powering [te.react.dev](htt
77
### Prerequisites
88

99
1. Git
10-
1. Node: any version starting with v16.8.0 or greater
11-
1. Yarn: See [Yarn website for installation instructions](https://yarnpkg.com/lang/en/docs/install/)
10+
1. Node: v24 or greater
11+
1. Yarn Classic: See [Yarn website for installation instructions](https://classic.yarnpkg.com/en/docs/install/)
1212
1. A fork of the repo (for any contributions)
1313
1. A clone of the [te.react.dev repo](https://github.com/reactjs/te.react.dev) on your local machine
1414

1515
### Installation
1616

17+
<<<<<<< HEAD
1718
1. `cd te.react.dev` to go into the project root
19+
=======
20+
1. `cd react.dev` to go into the project root
21+
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.
22+
>>>>>>> 46a54e0592729712b7640308b53268e84fdc7c9f
1823
3. `yarn` to install the website's npm dependencies
1924

2025
### Running locally
@@ -39,8 +44,8 @@ The documentation is divided into several sections with a different tone and pur
3944
1. Follow the ["Running locally"](#running-locally) instructions
4045
1. Save the files and check in the browser
4146
1. Changes to React components in `src` will hot-reload
42-
1. Changes to markdown files in `content` will hot-reload
43-
1. If working with plugins, you may need to remove the `.cache` directory and restart the server
47+
1. Changes to markdown files in `src/content` will hot-reload
48+
1. If working with plugins, you may need to remove the `node_modules/.cache/react-docs-mdx` directory and restart the server
4449

4550
### Test the change
4651

@@ -57,7 +62,11 @@ The documentation is divided into several sections with a different tone and pur
5762

5863
## Translation
5964

65+
<<<<<<< HEAD
6066
If you are interested in translating `te.react.dev`, please see the current translation efforts [here](https://github.com/reactjs/te.react.dev/issues/1).
67+
=======
68+
If you are interested in translating `react.dev`, please see the current translation efforts [here](https://react.dev/community/translations).
69+
>>>>>>> 46a54e0592729712b7640308b53268e84fdc7c9f
6170
6271
## License
6372
Content submitted to [te.react.dev](https://te-react-dev.vercel.app) is CC-BY-4.0 licensed, as found in the [LICENSE-DOCS.md](https://github.com/reactjs/te.react.dev/blob/main/LICENSE-DOCS.md) file.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"webpack-bundle-analyzer": "^4.5.0"
112112
},
113113
"engines": {
114-
"node": ">=16.8.0"
114+
"node": ">=24"
115115
},
116116
"nextBundleAnalysis": {
117117
"budget": null,

‎src/content/reference/react-dom/components/form.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ When you pass a function to `action`, React:
103103
* Propagates any errors to the nearest Error Boundary.
104104
* Resets the form's uncontrolled fields when the function succeeds. To keep their values, see [Preserving form values after an Action](#preserve-form-values-after-an-action).
105105

106+
If you handle submission manually, you can [request the same reset behavior with `requestFormReset`](/reference/react-dom/requestFormReset#requesting-a-reset-in-a-custom-form-action).
107+
106108
Because the Action runs in a Transition, you can also use [`useActionState`](/reference/react/useActionState) to manage form state and [`useOptimistic`](/reference/react/useOptimistic) for optimistic UI. For [Server Functions](/reference/rsc/server-functions) and progressive enhancement, see [Handling form submission with a Server Function](#handle-form-submission-with-a-server-function).
107109

108110
<Sandpack>
@@ -600,7 +602,7 @@ The examples above keep every submitted value by storing it before the reset. Yo
600602

601603
* **Skip the reset with `onSubmit`.** Handle the submission in `onSubmit`, call `e.preventDefault()`, and run the Action inside [`startTransition`](/reference/react/useTransition). Because the form's `action` does not run, React does not reset the form.
602604

603-
* **Reset at a specific moment.** Call the form element's [`reset()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset) method to immediately reset uncontrolled fields to their default values. To schedule a reset as part of an Action or Transition, call [`requestFormReset`](/blog/2024/12/05/react-19#form-actions) from `react-dom` instead.
605+
* **Reset at a specific moment.** Call the form element's [`reset()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset) method to immediately reset uncontrolled fields to their default values. To schedule a reset as part of an Action or Transition, call [`requestFormReset`](/reference/react-dom/requestFormReset) from `react-dom` instead.
604606

605607
* **Reset the form and the component state together.** Change the [`key`](/learn/preserving-and-resetting-state#resetting-a-form-with-a-key) of the component that renders the form. React recreates the component and its DOM, which resets the fields and any local state.
606608

‎src/content/reference/react-dom/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ These APIs can be imported from your components. They are rarely used:
1616

1717
* [`createPortal`](/reference/react-dom/createPortal) lets you render child components in a different part of the DOM tree.
1818
* [`flushSync`](/reference/react-dom/flushSync) lets you force React to flush a state update and update the DOM synchronously.
19+
* [`requestFormReset`](/reference/react-dom/requestFormReset) lets you request a form reset when handling submissions with custom Actions or Transitions.
1920

2021
## Resource Preloading APIs {/*resource-preloading-apis*/}
2122

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: requestFormReset
3+
---
4+
5+
<Intro>
6+
7+
`requestFormReset` lets you reset a React-managed form after an Action or Transition finishes.
8+
9+
```js
10+
requestFormReset(form)
11+
```
12+
13+
</Intro>
14+
15+
<InlineToc />
16+
17+
---
18+
19+
## Reference {/*reference*/}
20+
21+
### `requestFormReset(form)` {/*requestformreset*/}
22+
23+
Call `requestFormReset` to request that a form resets after the current Action or Transition completes.
24+
25+
```js
26+
import { startTransition } from 'react';
27+
import { requestFormReset } from 'react-dom';
28+
29+
function handleSubmit(form) {
30+
startTransition(async () => {
31+
const formData = new FormData(form);
32+
requestFormReset(form);
33+
await save(formData);
34+
});
35+
}
36+
```
37+
38+
[See more examples below.](#usage)
39+
40+
#### Parameters {/*parameters*/}
41+
42+
* `form`: an [HTML form element](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement) rendered by React.
43+
44+
#### Returns {/*returns*/}
45+
46+
`requestFormReset` returns nothing.
47+
48+
#### Caveats {/*caveats*/}
49+
50+
* Pass a form element that is rendered by React. Passing a non-form element, or a form not managed by React, throws an error.
51+
* `requestFormReset` is intended for Actions and Transitions. If called outside an Action or Transition, React warns in development and performs a synchronous reset.
52+
* `requestFormReset` is useful when you implement form submission logic yourself (for example with `onSubmit` + `startTransition`) and still want React's form reset behavior.
53+
* This API requests a reset for uncontrolled form fields. For controlled fields, handle resets by updating state, such as in `onReset`.
54+
55+
---
56+
57+
## Usage {/*usage*/}
58+
59+
### Requesting a reset in a custom form Action {/*requesting-a-reset-in-a-custom-form-action*/}
60+
61+
React [automatically resets uncontrolled fields after a successful `<form action={...}>` submission](/reference/react-dom/components/form#handle-form-submission-with-an-action-prop). When you implement submission manually, you can opt into the same behavior by calling `requestFormReset`.
62+
63+
```js
64+
import { startTransition } from 'react';
65+
import { requestFormReset } from 'react-dom';
66+
67+
function SearchForm() {
68+
async function onSubmit(event) {
69+
event.preventDefault();
70+
71+
const form = event.currentTarget;
72+
const formData = new FormData(form);
73+
74+
startTransition(async () => {
75+
requestFormReset(form);
76+
await submitSearch(formData);
77+
});
78+
}
79+
80+
return (
81+
<form onSubmit={onSubmit}>
82+
<input name="query" defaultValue="react" />
83+
<button type="submit">Search</button>
84+
</form>
85+
);
86+
}
87+
```
88+
89+
If your submission uses the built-in `<form action={...}>` behavior, you don't need to call `requestFormReset` manually.

0 commit comments

Comments
 (0)