Skip to content

Commit ba1d97c

Browse files
merging all conflicts
2 parents a953d8a + 7d50c3f commit ba1d97c

File tree

5 files changed

+38
-17
lines changed

5 files changed

+38
-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 @@ Use the conditional operator (`cond ? a : b`) to render a ❌ if `isPacked` isn
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: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,17 @@ export default function PackingList() {
5252
</Sandpack>
5353
5454

55+
<<<<<<< HEAD
5556
Обратите внимание, что у некоторых компонентов `Item` проп `isPacked` имеет значение `true`, вместо значения `false`. Если `isPacked={true}`, вы хотите добавить галочку(✔) к упакованным вещам.
57+
=======
58+
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}`.
59+
>>>>>>> 7d50c3ffd4df2dc7903f4e41069653a456a9c223
5660
5761
Можно реализовать это с помощью [управляющей конструкции `if`/`else`](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Statements/if...) таким образом:
5862

5963
```js
6064
if (isPacked) {
61-
return <li className="item">{name} </li>;
65+
return <li className="item">{name} </li>;
6266
}
6367
return <li className="item">{name}</li>;
6468
```
@@ -70,7 +74,7 @@ return <li className="item">{name}</li>;
7074
```js
7175
function Item({ name, isPacked }) {
7276
if (isPacked) {
73-
return <li className="item">{name} </li>;
77+
return <li className="item">{name} </li>;
7478
}
7579
return <li className="item">{name}</li>;
7680
}
@@ -159,7 +163,7 @@ export default function PackingList() {
159163
В предыдущем примере вы контролировали, какое JSX дерево будет возвращено компонентом (если вообще будет!). Возможно, вы уже заметили некоторое дублирование в выводе рендера:
160164

161165
```js
162-
<li className="item">{name} </li>
166+
<li className="item">{name} </li>
163167
```
164168

165169
очень похоже на
@@ -172,7 +176,7 @@ export default function PackingList() {
172176

173177
```js
174178
if (isPacked) {
175-
return <li className="item">{name} </li>;
179+
return <li className="item">{name} </li>;
176180
}
177181
return <li className="item">{name}</li>;
178182
```
@@ -187,7 +191,7 @@ return <li className="item">{name}</li>;
187191

188192
```js
189193
if (isPacked) {
190-
return <li className="item">{name} </li>;
194+
return <li className="item">{name} </li>;
191195
}
192196
return <li className="item">{name}</li>;
193197
```
@@ -197,12 +201,16 @@ return <li className="item">{name}</li>;
197201
```js
198202
return (
199203
<li className="item">
200-
{isPacked ? name + ' ' : name}
204+
{isPacked ? name + ' ' : name}
201205
</li>
202206
);
203207
```
204208

209+
<<<<<<< HEAD
205210
Вы можете читать это как *"если `isPacked` равно true, тогда (`?`) рендерим `name + ' ✔'`, в противном случае (`:`) рендерим `name`"*.
211+
=======
212+
You can read it as *"if `isPacked` is true, then (`?`) render `name + ' ✅'`, otherwise (`:`) render `name`"*.
213+
>>>>>>> 7d50c3ffd4df2dc7903f4e41069653a456a9c223
206214
207215
<DeepDive>
208216

@@ -222,7 +230,7 @@ function Item({ name, isPacked }) {
222230
<li className="item">
223231
{isPacked ? (
224232
<del>
225-
{name + ' '}
233+
{name + ' '}
226234
</del>
227235
) : (
228236
name
@@ -265,7 +273,7 @@ export default function PackingList() {
265273
```js
266274
return (
267275
<li className="item">
268-
{name} {isPacked && ''}
276+
{name} {isPacked && ''}
269277
</li>
270278
);
271279
```
@@ -280,7 +288,7 @@ return (
280288
function Item({ name, isPacked }) {
281289
return (
282290
<li className="item">
283-
{name} {isPacked && ''}
291+
{name} {isPacked && ''}
284292
</li>
285293
);
286294
}
@@ -337,7 +345,11 @@ let itemContent = name;
337345

338346
```js
339347
if (isPacked) {
348+
<<<<<<< HEAD
340349
itemContent = name + '';
350+
=======
351+
itemContent = name + "";
352+
>>>>>>> 7d50c3ffd4df2dc7903f4e41069653a456a9c223
341353
}
342354
```
343355

@@ -357,7 +369,11 @@ if (isPacked) {
357369
function Item({ name, isPacked }) {
358370
let itemContent = name;
359371
if (isPacked) {
372+
<<<<<<< HEAD
360373
itemContent = name + '';
374+
=======
375+
itemContent = name + "";
376+
>>>>>>> 7d50c3ffd4df2dc7903f4e41069653a456a9c223
361377
}
362378
return (
363379
<li className="item">
@@ -401,7 +417,7 @@ function Item({ name, isPacked }) {
401417
if (isPacked) {
402418
itemContent = (
403419
<del>
404-
{name + " "}
420+
{name + " "}
405421
</del>
406422
);
407423
}
@@ -464,7 +480,7 @@ export default function PackingList() {
464480
function Item({ name, isPacked }) {
465481
return (
466482
<li className="item">
467-
{name} {isPacked && ''}
483+
{name} {isPacked && ''}
468484
</li>
469485
);
470486
}
@@ -502,7 +518,7 @@ export default function PackingList() {
502518
function Item({ name, isPacked }) {
503519
return (
504520
<li className="item">
505-
{name} {isPacked ? '' : ''}
521+
{name} {isPacked ? '' : ''}
506522
</li>
507523
);
508524
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ In this example, the JavaScript `&&` operator is used to conditionally render a
327327
function Item({ name, isPacked }) {
328328
return (
329329
<li className="item">
330-
{name} {isPacked && ''}
330+
{name} {isPacked && ''}
331331
</li>
332332
);
333333
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ function Game() {
408408
409409
There are two problems with this code.
410410
411-
One 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.
411+
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.
412412
413-
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.
413+
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.
414414
415415
In this case, it's better to calculate what you can during rendering, and adjust the state in the event handler:
416416

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)