Skip to content

Commit 3901867

Browse files
Merge pull request #295 from reactjs/sync-7d50c3ff
Sync with react.dev @ 7d50c3f
2 parents f7c76eb + 79700e3 commit 3901867

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
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: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ export default function PackingList() {
5252
5353
</Sandpack>
5454
55-
ध्यान दें कि कुछ `Item` कौम्पोनॅन्ट का `isPacked` prop `false` के बजाय `true` पर सेट है। आप पैक किए गए आइटम में एक चेकमार्क () ऐड करना चाहते हैं यदि `isPacked={true}` है।
55+
ध्यान दें कि कुछ `Item` कौम्पोनॅन्ट का `isPacked` prop `false` के बजाय `true` पर सेट है। आप पैक किए गए आइटम में एक चेकमार्क () ऐड करना चाहते हैं यदि `isPacked={true}` है।
5656
5757
आप इसे [`if`/`else` स्टेटमेंट](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else) के रूप में लिख सकते हैं, इस तरह:
5858
5959
```js
6060
if (isPacked) {
61-
return <li className="item">{name} </li>;
61+
return <li className="item">{name} </li>;
6262
}
6363
return <li className="item">{name}</li>;
6464
```
@@ -70,7 +70,7 @@ return <li className="item">{name}</li>;
7070
```js
7171
function Item({ name, isPacked }) {
7272
if (isPacked) {
73-
return <li className="item">{name} </li>;
73+
return <li className="item">{name} </li>;
7474
}
7575
return <li className="item">{name}</li>;
7676
}
@@ -159,7 +159,7 @@ export default function PackingList() {
159159
पिछले उदाहरण में, आपने कण्ट्रोल किया था कि कौन सा (यदि कोई हो!) JSX ट्री कौम्पोनॅन्ट से लौटाया जाएगा। आपने पहले ही रेंडर आउटपुट में कुछ डुप्लीकेशन देखा होगा:
160160
161161
```js
162-
<li className="item">{name} </li>
162+
<li className="item">{name} </li>
163163
```
164164
165165
इससे बहुत समान है
@@ -172,7 +172,7 @@ export default function PackingList() {
172172
173173
```js
174174
if (isPacked) {
175-
return <li className="item">{name} </li>;
175+
return <li className="item">{name} </li>;
176176
}
177177
return <li className="item">{name}</li>;
178178
```
@@ -187,7 +187,7 @@ return <li className="item">{name}</li>;
187187
188188
```js
189189
if (isPacked) {
190-
return <li className="item">{name} </li>;
190+
return <li className="item">{name} </li>;
191191
}
192192
return <li className="item">{name}</li>;
193193
```
@@ -197,12 +197,12 @@ return <li className="item">{name}</li>;
197197
```js
198198
return (
199199
<li className="item">
200-
{isPacked ? name + ' ' : name}
200+
{isPacked ? name + ' ' : name}
201201
</li>
202202
);
203203
```
204204
205-
आप इसे इस प्रकार पढ़ सकते हैं *"यदि `isPacked` true है, तो (`?`) `name +''` रेंडर करें, नहीं तो (`:`) `name` रेंडर करें।"*)
205+
आप इसे इस प्रकार पढ़ सकते हैं *"यदि `isPacked` true है, तो (`?`) `name + ''` रेंडर करें, नहीं तो (`:`) `name` रेंडर करें।"*
206206
207207
<DeepDive>
208208
@@ -223,7 +223,7 @@ function Item({ name, isPacked }) {
223223
<li className="item">
224224
{isPacked ? (
225225
<del>
226-
{name + ' '}
226+
{name + ' '}
227227
</del>
228228
) : (
229229
name
@@ -266,7 +266,7 @@ export default function PackingList() {
266266
```js
267267
return (
268268
<li className="item">
269-
{name} {isPacked && ''}
269+
{name} {isPacked && ''}
270270
</li>
271271
);
272272
```
@@ -281,7 +281,7 @@ return (
281281
function Item({ name, isPacked }) {
282282
return (
283283
<li className="item">
284-
{name} {isPacked && ''}
284+
{name} {isPacked && ''}
285285
</li>
286286
);
287287
}
@@ -337,7 +337,7 @@ let itemContent = name;
337337
338338
```js
339339
if (isPacked) {
340-
itemContent = name + " ";
340+
itemContent = name + " ";
341341
}
342342
```
343343
@@ -357,7 +357,7 @@ if (isPacked) {
357357
function Item({ name, isPacked }) {
358358
let itemContent = name;
359359
if (isPacked) {
360-
itemContent = name + " ";
360+
itemContent = name + " ";
361361
}
362362
return (
363363
<li className="item">
@@ -401,7 +401,7 @@ function Item({ name, isPacked }) {
401401
if (isPacked) {
402402
itemContent = (
403403
<del>
404-
{name + " "}
404+
{name + " "}
405405
</del>
406406
);
407407
}
@@ -464,7 +464,7 @@ export default function PackingList() {
464464
function Item({ name, isPacked }) {
465465
return (
466466
<li className="item">
467-
{name} {isPacked && ''}
467+
{name} {isPacked && ''}
468468
</li>
469469
);
470470
}
@@ -502,7 +502,7 @@ export default function PackingList() {
502502
function Item({ name, isPacked }) {
503503
return (
504504
<li className="item">
505-
{name} {isPacked ? '' : ''}
505+
{name} {isPacked ? '' : ''}
506506
</li>
507507
);
508508
}

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)