diff --git a/src/content/learn/removing-effect-dependencies.md b/src/content/learn/removing-effect-dependencies.md index 86e0817d04..88666bb892 100644 --- a/src/content/learn/removing-effect-dependencies.md +++ b/src/content/learn/removing-effect-dependencies.md @@ -1240,7 +1240,11 @@ export default function Timer() { +<<<<<<< HEAD 你不应在 Effect 中读取 `count`,而是将 `c => c + 1` 指令(“增加此数字!”)传递给 React。React 将在下一次渲染时执行它。由于你不再需要读取 Effect 中 `count` 的值,因此你可以将 Effect 的依赖保持为空(`[]`)。这可以防止 Effect 在每次执行时重新创建定时器 interval。 +======= +Instead of reading `count` inside the Effect, you pass a `c => c + 1` instruction ("increment this number!") to React. React will apply it on the next render. And since you don't need to read the value of `count` inside your Effect anymore, you can keep your Effect's dependencies empty (`[]`). This prevents your Effect from re-creating the interval on every tick. +>>>>>>> f15830d5a1eec60d474a57e700f3acba5eb65659 diff --git a/src/content/learn/reusing-logic-with-custom-hooks.md b/src/content/learn/reusing-logic-with-custom-hooks.md index 8a60040358..a3929b9be3 100644 --- a/src/content/learn/reusing-logic-with-custom-hooks.md +++ b/src/content/learn/reusing-logic-with-custom-hooks.md @@ -820,7 +820,11 @@ export default function ChatRoom({ roomId }) { // ... ``` +<<<<<<< HEAD 并把它作为输入传给另一个 Hook: +======= +and passing it as an input to another Hook: +>>>>>>> f15830d5a1eec60d474a57e700f3acba5eb65659 ```js {6} export default function ChatRoom({ roomId }) { diff --git a/src/content/learn/separating-events-from-effects.md b/src/content/learn/separating-events-from-effects.md index fc7a7b5a6c..7c155a36bf 100644 --- a/src/content/learn/separating-events-from-effects.md +++ b/src/content/learn/separating-events-from-effects.md @@ -973,6 +973,23 @@ Effect Event 是 Effect 代码的非响应式“片段”。他们应该在使 +```json package.json hidden +{ + "dependencies": { + "react": "experimental", + "react-dom": "experimental", + "react-scripts": "latest" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + } +} +``` + + ```js import { useState, useEffect } from 'react'; @@ -1026,6 +1043,22 @@ button { margin: 10px; } +```json package.json hidden +{ + "dependencies": { + "react": "experimental", + "react-dom": "experimental", + "react-scripts": "latest" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + } +} +``` + ```js import { useState, useEffect } from 'react'; diff --git a/src/content/reference/react-dom/preinit.md b/src/content/reference/react-dom/preinit.md index cd56a04fc5..34826a7dd7 100644 --- a/src/content/reference/react-dom/preinit.md +++ b/src/content/reference/react-dom/preinit.md @@ -44,6 +44,7 @@ function AppRoot() { #### 参数 {/*parameters*/} +<<<<<<< HEAD * `href`:字符串,要下载并执行的资源的 URL。 * `options`:对象,可以包含以下属性: * `as`:必需的字符串,表示资源的类型,可能的值包括 `script` 与 `style`。 @@ -52,6 +53,16 @@ function AppRoot() { * `integrity`:字符串,为资源的加密哈希,用于 [验证其真实性](https://developer.mozilla.org/zh-CN/docs/Web/Security/Subresource_Integrity)。 * `nonce`:字符串,表示使用严格内容安全策略时允许资源的 [加密随机数](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Global_attributes/nonce)。 * `fetchPriority`:字符串,表示建议获取资源的相对优先级,可能的值为 `auto`(默认值)、`high` 与 `low`。 +======= +* `href`: a string. The URL of the resource you want to download and execute. +* `options`: an object. It contains the following properties: + * `as`: a required string. The type of resource. Its possible values are `script` and `style`. + * `precedence`: a string. Required with stylesheets. Says where to insert the stylesheet relative to others. Stylesheets with higher precedence can override those with lower precedence. The possible values are `reset`, `low`, `medium`, `high`. + * `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`. + * `integrity`: a string. A cryptographic hash of the resource, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). + * `nonce`: a string. A cryptographic [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy. + * `fetchPriority`: a string. Suggests a relative priority for fetching the resource. The possible values are `auto` (the default), `high`, and `low`. +>>>>>>> f15830d5a1eec60d474a57e700f3acba5eb65659 #### 返回值 {/*returns*/}