Skip to content

Commit b48adfc

Browse files
committed
docs(en): merging all conflicts
2 parents a8f95df + 7d50c3f commit b48adfc

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed

src/content/blog/2023/03/16/introducing-react-dev.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ body {
269269
function Item({ name, isPacked }) {
270270
return (
271271
<li className="item">
272-
{name} {isPacked && ''}
272+
{name} {isPacked && ''}
273273
</li>
274274
);
275275
}
@@ -307,7 +307,7 @@ export default function PackingList() {
307307
function Item({ name, isPacked }) {
308308
return (
309309
<li className="item">
310-
{name} {isPacked ? '' : ''}
310+
{name} {isPacked ? '' : ''}
311311
</li>
312312
);
313313
}

src/content/learn/conditional-rendering.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ export default function PackingList() {
5454

5555
</Sandpack>
5656

57+
<<<<<<< HEAD
5758
需要注意的是,有些 `Item` 组件的 `isPacked` 属性是被设为 `true` 而不是 `false`。你可以在那些满足 `isPacked={true}` 条件的物品旁加上一个勾选符号(✔)。
59+
=======
60+
Notice that some of the `Item` components have their `isPacked` prop set to `true` instead of `false`. You want to add a checkmark (✅) to packed items if `isPacked={true}`.
61+
>>>>>>> 7d50c3ffd4df2dc7903f4e41069653a456a9c223
5862
5963
你可以用 [if/else 语句](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/if...else) 去判断:
6064

6165
```js
6266
if (isPacked) {
63-
return <li className="item">{name} </li>;
67+
return <li className="item">{name} </li>;
6468
}
6569
return <li className="item">{name}</li>;
6670
```
@@ -72,7 +76,7 @@ return <li className="item">{name}</li>;
7276
```js
7377
function Item({ name, isPacked }) {
7478
if (isPacked) {
75-
return <li className="item">{name} </li>;
79+
return <li className="item">{name} </li>;
7680
}
7781
return <li className="item">{name}</li>;
7882
}
@@ -161,7 +165,7 @@ export default function PackingList() {
161165
在之前的例子里,你在组件内部控制哪些 JSX 树(如果有的话!)会返回。你可能已经发现了在渲染输出里会有一些重复的内容:
162166

163167
```js
164-
<li className="item">{name} </li>
168+
<li className="item">{name} </li>
165169
```
166170

167171
和下面的写法很像:
@@ -174,7 +178,7 @@ export default function PackingList() {
174178

175179
```js
176180
if (isPacked) {
177-
return <li className="item">{name} </li>;
181+
return <li className="item">{name} </li>;
178182
}
179183
return <li className="item">{name}</li>;
180184
```
@@ -189,7 +193,7 @@ JavaScript 有一种紧凑型语法来实现条件判断表达式——[条件
189193

190194
```js
191195
if (isPacked) {
192-
return <li className="item">{name} </li>;
196+
return <li className="item">{name} </li>;
193197
}
194198
return <li className="item">{name}</li>;
195199
```
@@ -199,12 +203,16 @@ return <li className="item">{name}</li>;
199203
```js
200204
return (
201205
<li className="item">
202-
{isPacked ? name + ' ' : name}
206+
{isPacked ? name + ' ' : name}
203207
</li>
204208
);
205209
```
206210

211+
<<<<<<< HEAD
207212
你可以认为,*“如果 `isPacked` 为 true 时,则(`?`)渲染 `name + ' ✔'`,否则(`:`)渲染 `name`。”*
213+
=======
214+
You can read it as *"if `isPacked` is true, then (`?`) render `name + ' ✅'`, otherwise (`:`) render `name`"*.
215+
>>>>>>> 7d50c3ffd4df2dc7903f4e41069653a456a9c223
208216
209217
<DeepDive>
210218

@@ -224,7 +232,7 @@ function Item({ name, isPacked }) {
224232
<li className="item">
225233
{isPacked ? (
226234
<del>
227-
{name + ' '}
235+
{name + ' '}
228236
</del>
229237
) : (
230238
name
@@ -267,7 +275,7 @@ export default function PackingList() {
267275
```js
268276
return (
269277
<li className="item">
270-
{name} {isPacked && ''}
278+
{name} {isPacked && ''}
271279
</li>
272280
);
273281
```
@@ -282,7 +290,7 @@ return (
282290
function Item({ name, isPacked }) {
283291
return (
284292
<li className="item">
285-
{name} {isPacked && ''}
293+
{name} {isPacked && ''}
286294
</li>
287295
);
288296
}
@@ -339,7 +347,7 @@ let itemContent = name;
339347

340348
```js
341349
if (isPacked) {
342-
itemContent = name + " ";
350+
itemContent = name + " ";
343351
}
344352
```
345353

@@ -359,7 +367,7 @@ if (isPacked) {
359367
function Item({ name, isPacked }) {
360368
let itemContent = name;
361369
if (isPacked) {
362-
itemContent = name + " ";
370+
itemContent = name + " ";
363371
}
364372
return (
365373
<li className="item">
@@ -403,7 +411,7 @@ function Item({ name, isPacked }) {
403411
if (isPacked) {
404412
itemContent = (
405413
<del>
406-
{name + " "}
414+
{name + " "}
407415
</del>
408416
);
409417
}
@@ -466,7 +474,7 @@ export default function PackingList() {
466474
function Item({ name, isPacked }) {
467475
return (
468476
<li className="item">
469-
{name} {isPacked && ''}
477+
{name} {isPacked && ''}
470478
</li>
471479
);
472480
}
@@ -504,7 +512,7 @@ export default function PackingList() {
504512
function Item({ name, isPacked }) {
505513
return (
506514
<li className="item">
507-
{name} {isPacked ? '' : ''}
515+
{name} {isPacked ? '' : ''}
508516
</li>
509517
);
510518
}

src/content/learn/describing-the-ui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export function getImageUrl(person, size = 's') {
330330
function Item({ name, isPacked }) {
331331
return (
332332
<li className="item">
333-
{name} {isPacked && ''}
333+
{name} {isPacked && ''}
334334
</li>
335335
);
336336
}

src/content/learn/you-might-not-need-an-effect.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,15 @@ function Game() {
408408
409409
这段代码里有两个问题。
410410
411+
<<<<<<< HEAD
411412
一个问题是它非常低效:在链式的每个 `set` 调用之间,组件(及其子组件)都不得不重新渲染。在上面的例子中,在最坏的情况下(`setCard` → 渲染 → `setGoldCardCount` → 渲染 → `setRound` → 渲染 → `setIsGameOver` → 渲染)有三次不必要的重新渲染。
412413
413414
即使不考虑渲染效率问题,随着代码不断扩展,你会遇到这条 “链式” 调用不符合新需求的情况。试想一下,你现在需要添加一种方法来回溯游戏的历史记录,可以通过更新每个 state 变量到之前的值来实现。然而,将 `card` 设置为之前的的某个值会再次触发 Effect 链并更改你正在显示的数据。这样的代码往往是僵硬而脆弱的。
415+
=======
416+
First problem is that it is very inefficient: the component (and its children) have to re-render between each `set` call in the chain. In the example above, in the worst case (`setCard` → render → `setGoldCardCount` → render → `setRound` → render → `setIsGameOver` → render) there are three unnecessary re-renders of the tree below.
417+
418+
The second problem is that even if it weren't slow, as your code evolves, you will run into cases where the "chain" you wrote doesn't fit the new requirements. Imagine you are adding a way to step through the history of the game moves. You'd do it by updating each state variable to a value from the past. However, setting the `card` state to a value from the past would trigger the Effect chain again and change the data you're showing. Such code is often rigid and fragile.
419+
>>>>>>> 7d50c3ffd4df2dc7903f4e41069653a456a9c223
414420
415421
在这个例子中,更好的做法是:尽可能在渲染期间进行计算,以及在事件处理函数中调整 state:
416422

vercel.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"destination": "/learn/rendering-lists#keeping-list-items-in-order-with-key",
2525
"permanent": false
2626
},
27+
{
28+
"source": "/docs/lists-and-keys",
29+
"destination": "/learn/rendering-lists#keeping-list-items-in-order-with-key",
30+
"permanent": false
31+
},
2732
{
2833
"source": "/link/invalid-hook-call",
2934
"destination": "/warnings/invalid-hook-call-warning",

0 commit comments

Comments
 (0)