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
This example shows a message when you press the button. However, pressing the button also accidentally resets the input. Why does this happen? Fix it so that pressing the button does not reset the input text.
1269
+
Bu örnek butona tıkladığınız zaman bir mesaj göstermektedir. Ancak, butona tıkalamak aynı zamanda input'u da sıfırlamaktadır. Sizce bu niye olmakta? Butona tıklamanın input metnini sıfırlamayacağı şekilde düzeltin.
1270
1270
1271
1271
<Sandpack>
1272
1272
@@ -1278,11 +1278,11 @@ export default function App() {
1278
1278
if (showHint) {
1279
1279
return (
1280
1280
<div>
1281
-
<p><i>Hint: Your favorite city?</i></p>
1281
+
<p><i>İpucu: Favori şehriniz?</i></p>
1282
1282
<Form />
1283
1283
<button onClick={() => {
1284
1284
setShowHint(false);
1285
-
}}>Hide hint</button>
1285
+
}}>İpucunu gizle</button>
1286
1286
</div>
1287
1287
);
1288
1288
}
@@ -1291,7 +1291,7 @@ export default function App() {
The problem is that `Form` is rendered in different positions. In the `if` branch, it is the second child of the `<div>`, but in the `else` branch, it is the first child. Therefore, the component type in each position changes. The first position changes between holding a `p` and a `Form`, while the second position changes between holding a `Form` and a `button`. React resets the state every time the component type changes.
1318
+
Burdaki sorun `Form'un` farklı konumlarda render edilmesidir. `if`dalında `<div>`'in ikinci alt elemanıdır, ancak `else` dalında ilk alt elemanıdır. Bu nedenle, her konumdaki bileşen tipi değişir. Birinci konum `p` ve `Form` arasında değişirken, ikinci konum `Form` ve `button` arasında değişir. React, bileşen tipi her değiştiğinde state'i sıfırlar.
1319
1319
1320
-
The easiest solution is to unify the branches so that `Form` always renders in the same position:
1320
+
En kolay çözüm, `Form'un` her zaman aynı konumda render edilmesi için dalları birleştirmektir:
1321
1321
1322
1322
<Sandpack>
1323
1323
@@ -1329,17 +1329,17 @@ export default function App() {
This way, `Form` is always the second child, so it stays in the same position and keeps its state. But this approach is much less obvious and introduces a risk that someone else will remove that `null`.
1414
+
Bu şekilde`Form`her zaman ikinci alt elemandır yani her zaman aynı konumdadır ve state'i korur. Ancak bu yaklaşım daha az belirgindir ve başka birinin bu `null'u` silmesi riskini beraberinde getirir.
0 commit comments