You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/conditional-rendering.md
+22-14Lines changed: 22 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,13 +52,17 @@ export default function PackingList() {
52
52
53
53
</Sandpack>
54
54
55
+
<<<<<<< HEAD
55
56
Bazı `Item` bileşenlerinin `isPacked` prop'unun `false` (`yanlış`) yerine `true` (`doğru`) olduğuna dikkat edin. Eğer bileşen prop'u `isPacked={true}` ise eşyaların yanında bir tik (✔) işareti olmalı.
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
56
60
57
61
Bunu bir [`if`/`else` ifadesi](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else) olarak şöyle yazabilirsiniz:
58
62
59
63
```js
60
64
if (isPacked) {
61
-
return <li className="item">{name} ✔</li>;
65
+
return <li className="item">{name} ✅</li>;
62
66
}
63
67
return <li className="item">{name}</li>;
64
68
```
@@ -70,7 +74,7 @@ Eğer `isPacked` prop'u `true` ise, bu kod **farklı bir JSX ağacı döndürür
70
74
```js
71
75
function Item({ name, isPacked }) {
72
76
if (isPacked) {
73
-
return <li className="item">{name} ✔</li>;
77
+
return <li className="item">{name} ✅</li>;
74
78
}
75
79
return <li className="item">{name}</li>;
76
80
}
@@ -159,7 +163,7 @@ Uygulamada, bir bileşenin `null` döndürmesi yaygın olarak kullanılan bir ş
159
163
Önceki örnekte bileşen tarafından (eğer varsa!) hangi JSX ağacının döndüreleceğini belirlediniz. Render edilen çıktıda bazı tekrarlamalar olduğunu farketmişsinizdir:
160
164
161
165
```js
162
-
<li className="item">{name} ✔</li>
166
+
<li className="item">{name} ✅</li>
163
167
```
164
168
165
169
bu iki ifade birbirine çok benzemekte
@@ -172,7 +176,7 @@ Her iki koşul da `<li className="item">...</li>` ifadesini döndürmekte:
Copy file name to clipboardExpand all lines: src/content/learn/you-might-not-need-an-effect.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -411,9 +411,17 @@ function Game() {
411
411
412
412
Bir problem bu kodun çok verimsiz olmasıdır: bileşenin (ve onun alt elemanlarının) `set` çağrıları arasında her seferinde yeniden render edilmesidir. Yukarıdaki örnekte, en kötü durumda (`setCard` → render → `setGoldCardCount` → render → `setRound` → render → `setIsGameOver` → render) alt eleman ağacında üç gereksiz yeniden render işlemi gerçekleşir.
413
413
414
+
<<<<<<< HEAD
414
415
Hatta hızlı olmasa bile, kodunuz geliştikçe yeni gereksinimlere uygun olmayan durumlarla karşılaşabilirsiniz. Örneğin, oyun hareketlerinin geçmişini adım adım izlemek için bir yol eklemek istediğinizi düşünün. Her bir state değişkenini geçmişteki bir değere güncelleyerek bunu yapardınız. Ancak, `card` state'ini geçmişteki bir değere ayarlamak, Efekt zincirini tekrar tetikler ve gösterilen verileri değiştirir. Bu tür bir kod genellikle sert ve kırılgan olabilir.
415
416
416
417
Bu durumda, yapabileceğiniz hesaplamaları render işlemi sırasında gerçekleştirmek ve durumu olay yöneticisinde ayarlamak daha iyidir.
418
+
=======
419
+
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.
420
+
421
+
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.
422
+
423
+
In this case, it's better to calculate what you can during rendering, and adjust the state in the event handler:
0 commit comments