Skip to content

Commit ce2f2f5

Browse files
authored
docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ 721479b (#1376)
2 parents 2cca5cf + 53ee160 commit ce2f2f5

File tree

9 files changed

+47
-42
lines changed

9 files changed

+47
-42
lines changed

src/components/Layout/Feedback.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ const thumbsDownIcon = (
4545
);
4646

4747
function sendGAEvent(isPositive: boolean) {
48+
const value = isPositive ? 1 : 0;
4849
// Fragile. Don't change unless you've tested the network payload
4950
// and verified that the right events actually show up in GA.
5051
// @ts-ignore
5152
gtag('event', 'feedback', {
5253
event_category: 'button',
5354
event_label: window.location.pathname,
54-
value: isPositive ? 1 : 0,
55+
value,
5556
});
5657
}
5758

src/components/MDX/MDXComponents.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function Illustration({
243243
src={src}
244244
alt={alt}
245245
style={{maxHeight: 300}}
246-
className="bg-white rounded-lg"
246+
className="rounded-lg"
247247
/>
248248
{caption ? (
249249
<figcaption className="text-center leading-tight mt-4">
@@ -275,7 +275,12 @@ function IllustrationBlock({
275275
const images = imageInfos.map((info, index) => (
276276
<figure key={index}>
277277
<div className="bg-white rounded-lg p-4 flex-1 flex xl:p-6 justify-center items-center my-4">
278-
<img src={info.src} alt={info.alt} height={info.height} />
278+
<img
279+
className="text-primary"
280+
src={info.src}
281+
alt={info.alt}
282+
height={info.height}
283+
/>
279284
</div>
280285
{info.caption ? (
281286
<figcaption className="text-secondary dark:text-secondary-dark text-center leading-tight mt-4">

src/content/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ title: "React Labs:我们正在努力的方向——2022 年 6 月"
2828

2929
## 资源加载 {/*asset-loading*/}
3030

31-
目前,像脚本、外部样式、字体和图像等资源通常是通过预加载和外部系统加载的。这可能在新的环境(如流媒体、服务器组件等)之间协调起来比较棘手。
31+
目前,像脚本、外部样式、字体和图像等资源通常是通过外部系统预加载和加载的。这可能在新的环境(如跨流媒体、服务器组件等)之间协调起来比较棘手。
3232

33-
我们正在考虑通过 React API 添加预加载和加载去重的外部资源的 API,以在所有 React 环境中使用
33+
我们正在考虑添加 API,以通过适用于所有 React 环境的 React API 来预加载和加载经过重复数据删除的外部资源
3434

3535
我们还正在研究如何支持 Suspense,这样就可以拥有在加载完成之前阻塞显示的图像、CSS 和字体,但不会阻塞流媒体和并发渲染。这可以帮助避免视觉上的 [popcorning](https://twitter.com/sebmarkbage/status/1516852731251724293) 现象,即视觉效果的突然出现和布局的变化
3636

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ export default function Search() {
9393

9494
### Handle form submission with a Server Action {/*handle-form-submission-with-a-server-action*/}
9595

96-
Render a `<form>` with an input and submit button. Pass a server action (a function marked with [`'use server'`](/reference/react/use-server)) to the `action` prop of form to run the function when the form is submitted.
96+
Render a `<form>` with an input and submit button. Pass a Server Action (a function marked with [`'use server'`](/reference/react/use-server)) to the `action` prop of form to run the function when the form is submitted.
9797

98-
Passing a server action to `<form action>` allow users to submit forms without JavaScript enabled or before the code has loaded. This is beneficial to users who have a slow connection, device, or have JavaScript disabled and is similar to the way forms work when a URL is passed to the `action` prop.
98+
Passing a Server Action to `<form action>` allow users to submit forms without JavaScript enabled or before the code has loaded. This is beneficial to users who have a slow connection, device, or have JavaScript disabled and is similar to the way forms work when a URL is passed to the `action` prop.
9999

100-
You can use hidden form fields to provide data to the `<form>`'s action. The server action will be called with the hidden form field data as an instance of [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
100+
You can use hidden form fields to provide data to the `<form>`'s action. The Server Action will be called with the hidden form field data as an instance of [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
101101

102102
```jsx
103103
import { updateCart } from './lib.js';

src/content/reference/react-dom/hooks/useFormState.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function StatefulForm({}) {
5151

5252
The form state is the value returned by the action when the form was last submitted. If the form has not yet been submitted, it is the initial state that you pass.
5353

54-
If used with a server action, `useFormState` allows the server's response from submitting the form to be shown even before hydration has completed.
54+
If used with a Server Action, `useFormState` allows the server's response from submitting the form to be shown even before hydration has completed.
5555

5656
[See more examples below.](#usage)
5757

@@ -117,7 +117,7 @@ function action(currentState, formData) {
117117

118118
#### Display form errors {/*display-form-errors*/}
119119

120-
To display messages such as an error message or toast that's returned by a server action, wrap the action in a call to `useFormState`.
120+
To display messages such as an error message or toast that's returned by a Server Action, wrap the action in a call to `useFormState`.
121121

122122
<Sandpack>
123123

@@ -190,7 +190,7 @@ form button {
190190

191191
#### Display structured information after submitting a form {/*display-structured-information-after-submitting-a-form*/}
192192

193-
The return value from a server action can be any serializable value. For example, it could be an object that includes a boolean indicating whether the action was successful, an error message, or updated information.
193+
The return value from a Server Action can be any serializable value. For example, it could be an object that includes a boolean indicating whether the action was successful, an error message, or updated information.
194194

195195
<Sandpack>
196196

src/content/reference/react/use-client.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ As dependencies of `RichTextEditor`, `formatDate` and `Button` will also be eval
5252
* When a `'use client'` module is imported from another client-rendered module, the directive has no effect.
5353
* When a component module contains a `'use client'` directive, any usage of that component is guaranteed to be a Client Component. However, a component can still be evaluated on the client even if it does not have a `'use client'` directive.
5454
* A component usage is considered a Client Component if it is defined in module with `'use client'` directive or when it is a transitive dependency of a module that contains a `'use client'` directive. Otherwise, it is a Server Component.
55-
* Code that is marked for client evaluation is not limited to components. All code that is a part of the client module sub-tree is sent to and run by the client.
55+
* Code that is marked for client evaluation is not limited to components. All code that is a part of the Client module sub-tree is sent to and run by the client.
5656
* When a server evaluated module imports values from a `'use client'` module, the values must either be a React component or [supported serializable prop values](#passing-props-from-server-to-client-components) to be passed to a Client Component. Any other use case will throw an exception.
5757

5858
### How `'use client'` marks client code {/*how-use-client-marks-client-code*/}
5959

6060
In a React app, components are often split into separate files, or [modules](/learn/importing-and-exporting-components#exporting-and-importing-a-component).
6161

62-
For apps that use React Server Components, the app is server-rendered by default. `'use client'` introduces a server-client boundary in the [module dependency tree](/learn/understanding-your-ui-as-a-tree#the-module-dependency-tree), effectively creating a subtree of client modules.
62+
For apps that use React Server Components, the app is server-rendered by default. `'use client'` introduces a server-client boundary in the [module dependency tree](/learn/understanding-your-ui-as-a-tree#the-module-dependency-tree), effectively creating a subtree of Client modules.
6363

6464
To better illustrate this, consider the following React Server Components app.
6565

@@ -146,7 +146,7 @@ export default [
146146

147147
</Sandpack>
148148

149-
In the module dependency tree of this example app, the `'use client'` directive in `InspirationGenerator.js` marks that module and all of its transitive dependencies as client modules. The subtree starting at `InspirationGenerator.js` is now marked as client modules.
149+
In the module dependency tree of this example app, the `'use client'` directive in `InspirationGenerator.js` marks that module and all of its transitive dependencies as Client modules. The subtree starting at `InspirationGenerator.js` is now marked as Client modules.
150150

151151
<Diagram name="use_client_module_dependency" height={250} width={545} alt="A tree graph with the top node representing the module 'App.js'. 'App.js' has three children: 'Copyright.js', 'FancyText.js', and 'InspirationGenerator.js'. 'InspirationGenerator.js' has two children: 'FancyText.js' and 'inspirations.js'. The nodes under and including 'InspirationGenerator.js' have a yellow background color to signify that this sub-graph is client-rendered due to the 'use client' directive in 'InspirationGenerator.js'.">
152152
`'use client'` segments the module dependency tree of the React Server Components app, marking `InspirationGenerator.js` and all of its dependencies as client-rendered.
@@ -238,7 +238,7 @@ With `'use client'`, you can determine when components are Client Components. As
238238
For simplicity, we talk about Server Components, but the same principles apply to all code in your app that is server run.
239239

240240
#### Advantages of Server Components {/*advantages*/}
241-
* Server Components can reduce the amount of code sent and run by the client. Only client modules are bundled and evaluated by the client.
241+
* Server Components can reduce the amount of code sent and run by the client. Only Client modules are bundled and evaluated by the client.
242242
* Server Components benefit from running on the server. They can access the local filesystem and may experience low latency for data fetches and network requests.
243243

244244
#### Limitations of Server Components {/*limitations*/}
@@ -270,7 +270,7 @@ Serializable props include:
270270
* [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) and [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
271271
* [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
272272
* Plain [objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object): those created with [object initializers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer), with serializable properties
273-
* Functions that are [server actions](/reference/react/use-server)
273+
* Functions that are [Server Actions](/reference/react/use-server)
274274
* Client or Server Component elements (JSX)
275275
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
276276

0 commit comments

Comments
 (0)