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
@@ -1030,11 +1030,7 @@ export default function App() {
1030
1030
}
1031
1031
```
1032
1032
1033
-
<<<<<<< HEAD
1034
-
<CodeStep step={2}>İstemci Bileşeni</CodeStep> prop olarak iletilen Promise'i alır ve <CodeStep step={5}>`use`</CodeStep> API'ına ileterek kullanır. Bu yöntem Sunucu Bileşeni içerisinde oluşturulan <CodeStep step={4}>Promise</CodeStep>'ten alınan verinin <CodeStep step={2}>İstemci Bileşeni</CodeStep> tarafından okunmasına olanak tanır.
1035
-
=======
1036
-
The Client Component then takes the Promise it received as a prop and passes it to the `use` API. This allows the Client Component to read the value from the Promise that was initially created by the Server Component.
1037
-
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
1033
+
Client Component daha sonra prop olarak aldığı Promise’i alır ve `use` API’sine geçirir. Bu, Client Component’in başlangıçta Server Component tarafından oluşturulan Promise’ten gelen değeri okumasını sağlar.
1038
1034
1039
1035
```js
1040
1036
// message.js
@@ -1047,12 +1043,7 @@ export function Message({ messagePromise }) {
1047
1043
return<p>Aktarılan Mesaj: {messageContent}</p>;
1048
1044
}
1049
1045
```
1050
-
<<<<<<< HEAD
1051
-
1052
-
<CodeStep step={2}>`Message`</CodeStep> bir <CodeStep step={3}>[`Suspense`](/reference/react/Suspense)</CodeStep> içerisinde olduğu için Promise çözümleninceye kadar yedek görünüm görüntülenecektir. Promise çözümlendiğinde değer <CodeStep step={5}>`use`</CodeStep> API tarafından okunacak ve <CodeStep step={2}>`Message`</CodeStep> bileşeni Suspense'in yedek görünüm ile yer değiştirecektir.
1053
-
=======
1054
-
Because `Message` is wrapped in a [Suspense](/reference/react/Suspense) boundary, the fallback will be displayed until the Promise is resolved. When the Promise is resolved, the value will be read by the `use` API and the `Message` component will replace the Suspense fallback.
1055
-
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
1046
+
`Message`, bir [Suspense](/reference/react/Suspense) boundary’si ile sarıldığı için, Promise resolve edilene kadar fallback gösterilir. Promise resolve edildiğinde, değer `use` API’si tarafından okunur ve `Message` component’i Suspense fallback’inin yerini alır.
1056
1047
1057
1048
<Sandpack>
1058
1049
@@ -1119,65 +1110,29 @@ root.render(
1119
1110
1120
1111
</Sandpack>
1121
1112
1122
-
<<<<<<< HEAD
1123
-
<Note>
1124
-
1125
-
Sunucu Bileşeni'nden İstemci Bileşeni'ne Promise aktarıldığında çözümlenen değer sunucu ile istemci arasından geçmesi için serileştirilebilir olması gerekir. Fonksiyonlar gibi veri türleri serileştirilemezler ve Promise'in çözümlenen değeri olamazlar.
1126
-
1127
-
</Note>
1128
-
1129
-
1130
-
=======
1131
-
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
1132
1113
<DeepDive>
1133
1114
1134
1115
#### Promise'i Sunucu Bileşeninde mi yoksa İstemci Bileşeninde mi çözümlemeliyim? {/*resolve-promise-in-server-or-client-component*/}
1135
1116
1136
-
<<<<<<< HEAD
1137
-
Promise, Sunucu Bileşeni'nden İstemci Bileşeni'ne aktarılabilir ve İstemci Bileşeni içerisinde `use` API kullanarak çözümlenebilir. Yanı sıra istersen Promise'i Sunucu Bileşeni içerisinde `await` kullanarak çözümleyebilir ve gerekli veriyi İstemci Bileşeni içerisine prop olarak iletebilirsin.
1138
-
=======
1139
-
A Promise can be resolved with `await` in a Server Component, or passed as a prop to a Client Component and resolved there with `use`.
1117
+
Bir Promise, bir Server Component içinde `await` ile resolve edilebilir veya bir Client Component’e prop olarak geçirilip orada `use` ile resolve edilebilir.
1140
1118
1141
-
Using `await` in a Server Component suspends the Server Component itself, and the Client Component receives the resolved value as a prop:
1142
-
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
1119
+
Bir Server Component içinde `await` kullanmak Server Component’in kendisini suspend eder ve Client Component resolved value’yu prop olarak alır:
Ancak bir [Sunucu Bileşeninde](/reference/rsc/server-components) `await` kullanmak, `await` deyimi bitene kadar bileşenin oluşturulmasını engelleyecektir. Bir Sunucu Bileşeninden bir İstemci Bileşenine bir Promise geçirmek, Promise'in Sunucu Bileşeninin oluşturulmasını engellemesini önler.
1155
-
1156
-
</DeepDive>
1157
-
1158
-
### Reddedilen Promise'ler ile başa çıkmak {/*dealing-with-rejected-promises*/}
1159
-
1160
-
Bazen `use`'a aktarılan Promise reddedilebilir. Reddedilen Promise'leri şu şekilde yönetebilirsiniz:
1161
-
1162
-
1. [Error Boundary ile kullanıcılara hata gösterme](#displaying-an-error-to-users-with-error-boundary)
1163
-
2. [`Promise.catch` ile alternatif değer sağlama](#providing-an-alternative-value-with-promise-catch)
1164
-
1165
-
<Pitfall>
1166
-
`use`, try-catch bloğu içerisinde çağırılamaz. Try-catch bloğu yerine [bileşeni Error Boundary içerisine ekleyin](#displaying-an-error-to-users-with-error-boundary), ya da [Promise'in `.catch` methodundan yararlanarak alternatif bir değer sağlayın](#providing-an-alternative-value-with-promise-catch).
1167
-
</Pitfall>
1168
-
1169
-
#### Error Boundary ile kullanıcılara hata gösterme {/*displaying-an-error-to-users-with-error-boundary*/}
1170
-
1171
-
Bir Promise reddedildiğinde kullanıcıya hata göstermek istiyorsanız, [Error Boundary](/reference/react/Component#catching-rendering-errors-with-an-error-boundary) kullanabilirsiniz.
1172
-
Error Boundary kullanmak için, `use` API’sini çağırdığınız bileşeni bir Error Boundary ile sarın.
1173
-
Eğer `use` fonksiyonuna iletilen Promise reddedilirse, Error Boundary için tanımlanan fallback içerik görüntülenecektir.
1174
-
=======
1175
-
A Server Component can also start a Promise without awaiting it and pass the Promise to a Client Component. The Server Component returns immediately, and the Client Component suspends when it calls `use`:
1130
+
Bir Server Component ayrıca bir Promise’i await etmeden başlatabilir ve Promise’i bir Client Component’e geçirebilir. Server Component hemen return eder ve Client Component `use` çağırdığında suspend olur:
1176
1131
1177
1132
```js
1178
1133
// Server Component
1179
1134
exportdefaultfunctionApp() {
1180
-
//Not awaited: starts here, resolves on the client.
1135
+
//Await edilmedi: burada başlar, client’ta resolve olur.
@@ -1186,20 +1141,21 @@ export default function App() {
1186
1141
```js
1187
1142
// Client Component
1188
1143
'use client';
1144
+
1189
1145
import { use } from'react';
1190
1146
1191
1147
exportfunctionMessage({ messagePromise }) {
1192
-
//Will suspend until the data is available.
1148
+
//Data available olana kadar suspend eder.
1193
1149
constmessageContent=use(messagePromise);
1194
1150
return<p>{messageContent}</p>;
1195
1151
}
1196
1152
```
1197
1153
1198
-
Prefer `await` in a Server Component when possible, since it keeps the data fetching on the server. If a Server Component above already awaits the data, pass the resolved value down as a prop instead of creating a new Promise to call `use`.
1154
+
Mümkün olduğunda Server Component içinde `await` kullanmayı tercih edin; çünkü bu, data fetching’i server tarafında tutar. Eğer üstteki bir Server Component data’yı zaten await ediyorsa, `use` çağırmak için yeni bir Promise oluşturmak yerine resolved value’yu prop olarak aşağı geçirin.
1199
1155
1200
-
You can also pass promise as a prop to a Client Component without awaiting it, and then read it with `use(promise)`to suspend deeper in the tree. This allows more of the surrounding UI to complete while the Promise is pending. A common case is interactive content like popovers and tooltips, where the data is needed only after a hover or click. Client Components can't `await`, so they rely on `use` to suspend on a Promise.
1156
+
Ayrıca promise’i await etmeden bir Client Component’e prop olarak geçirebilir ve ardından tree’nin daha derininde suspend etmek için `use(promise)`ile okuyabilirsiniz. Bu, Promise pending durumdayken çevredeki UI’ın daha büyük bir kısmının tamamlanmasına olanak tanır. Yaygın bir durum, popover ve tooltip gibi interactive content’lerdir; burada data yalnızca hover veya click sonrasında gerekir. Client Component’ler `await` kullanamaz, bu yüzden bir Promise üzerinde suspend olmak için `use`’a güvenirler.
1201
1157
1202
-
In either case, wrap the component that reads the Promise in a Suspense boundary so React can show a fallback while the Promise is pending. See [Revealing content together at once](/reference/react/Suspense#revealing-content-together-at-once) for guidance on boundary placement.
1158
+
Her iki durumda da, Promise’i okuyan component’i bir Suspense boundary ile sarın; böylece React, Promise pending durumdayken bir fallback gösterebilir. Boundary placement konusunda rehberlik için [Revealing content together at once](/reference/react/Suspense#revealing-content-together-at-once) bölümüne bakın.
1203
1159
1204
1160
</DeepDive>
1205
1161
@@ -1210,7 +1166,6 @@ In either case, wrap the component that reads the Promise in a Suspense boundary
1210
1166
If the Promise passed to `use` is rejected, the error propagates to the nearest [Error Boundary](/reference/react/Component#catching-rendering-errors-with-an-error-boundary). Wrap the component that calls `use` in an Error Boundary to display a fallback when the Promise is rejected.
1211
1167
1212
1168
In the example below, `fetchData` rejects on the first attempt and succeeds on retry. The Error Boundary catches the rejection and shows a fallback with a "Try again" button.
1213
-
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
1214
1169
1215
1170
<Sandpack>
1216
1171
@@ -1231,33 +1186,22 @@ export default function App() {
1231
1186
}
1232
1187
1233
1188
return (
1234
-
<<<<<<<HEAD
1235
-
<ErrorBoundary fallback={<p>⚠️Bir şeyler yanlış gitti</p>}>
@@ -1357,7 +1266,6 @@ async function getData(url) {
1357
1266
}
1358
1267
thrownewError('Not implemented');
1359
1268
}
1360
-
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
1361
1269
```
1362
1270
1363
1271
```json package.json hidden
@@ -1373,116 +1281,63 @@ async function getData(url) {
1373
1281
```
1374
1282
</Sandpack>
1375
1283
1376
-
<<<<<<<HEAD
1377
-
#### `Promise.catch` methodunu kullanarak alternatif bir veri sunmak {/*providing-an-alternative-value-with-promise-catch*/}
1378
-
1379
-
Eğer `use`'a aktarılan Promise reddedildiğinde yerine alternatif bir değer sağlamak istiyorsan Promise'in<CodeStep step={1}>[`catch`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)</CodeStep> methodunu kullanabilirsin.
1380
-
1381
-
```js [[1, 6, "catch"],[2, 7, "return"]]
1382
-
import { Message } from './message.js';
1383
-
1384
-
export default function App() {
1385
-
const messagePromise = new Promise((resolve, reject) => {
1386
-
reject();
1387
-
}).catch(() => {
1388
-
return "yeni mesaj bulunamadı.";
1389
-
});
1390
-
1391
-
return (
1392
-
<Suspense fallback={<p>Mesaj bekleniyor...</p>}>
1393
-
<Message messagePromise={messagePromise} />
1394
-
</Suspense>
1395
-
);
1396
-
}
1397
-
```
1398
-
1399
-
Promise'in <CodeStep step={1}>`catch`</CodeStep> methodunu kullanmak için Promise objesinden <CodeStep step={1}>`catch`</CodeStep>'i çağır. <CodeStep step={1}>`catch`</CodeStep> tek bir argüman alır: Bir hata mesajını argüman olarak alan bir fonksiyon. <CodeStep step={1}>`catch`</CodeStep>'e geçirilen fonskiyon tarafından döndürülen her şey, Promise'in çözümlenen değeri olarak kullanılacaktır.
1400
-
1401
-
=======
1402
-
>>>>>>>2639f369946f763fff9a2572b0d7c4b9e2f83ebd
1403
1284
---
1404
1285
1405
1286
## Sorun Giderme {/*troubleshooting*/}
1406
1287
1407
-
<<<<<<<HEAD
1408
-
### "Suspense İstisnası: Bu gerçek bir hata değil!" {/*suspense-exception-error*/}
1409
-
1410
-
Ya `use` fonksiyonunu bir **React Component** veya **Hook** fonksiyonu dışında çağırıyorsunuz,
1411
-
ya da `use`’u bir **try–catch** bloğu içinde çağırıyorsunuz. Eğer `use`’u bir try–catch bloğu içinde çağırıyorsanız, bileşeninizi bir **Error Boundary** ile sarın,
1412
-
veya Promise’in`catch` metodunu kullanarak hatayı yakalayın ve Promise’i başka bir değerle çözümleyin (**resolve edin**). [Bu örneklere bakın](#dealing-with-rejected-promises).
1288
+
### Şu hatayı alıyorum: "Suspense Exception: This is not a real error!" {/*suspense-exception-error*/}
1413
1289
1414
-
Eğer `use`'u bir React Bileşeni veya Hook fonksiyonu dışında çağırıyorsanız `use` çağrısını bir React Bileşeni veya Hook fonksiyonu içerisine taşıyın.
1415
-
1416
-
```jsx
1417
-
function MessageComponent({messagePromise}) {
1418
-
function download() {
1419
-
// ❌ `use`, bir Bileşen veya Hook olmayan fonksiyon tarafından çağırılıyor
1420
-
const message = use(messagePromise);
1421
-
// ...
1422
-
```
1423
-
1424
-
Bunun yerine, `use` fonksiyonunu herhangi bir bileşen kapanışının dışında çağırın. `use` fonksiyonunu çağıran fonksiyon bir bileşen veya Hook olmalıdır.
1425
-
1426
-
```jsx
1427
-
function MessageComponent({messagePromise}) {
1428
-
// ✅ `use`, bir component’ten çağrılıyor.
1429
-
const message = use(messagePromise);
1430
-
// ...
1431
-
```
1432
-
=======
1433
-
### I'm getting an error:"Suspense Exception: This is not a real error!" {/*suspense-exception-error*/}
1434
-
1435
-
You are calling `use` inside a try-catch block. `use` throws internally to integrate with Suspense, so it cannot be wrapped intry-catch. Instead, wrap the component that calls `use`in an [Error Boundary](#displaying-an-error-with-an-error-boundary) to handle errors.
1290
+
`use`’u bir try-catch block’u içinde çağırıyorsunuz. `use`, Suspense ile entegre olmak için internal olarak throw eder, bu yüzden try-catch ile sarılamaz. Bunun yerine, error’ları handle etmek için `use` çağıran component’i bir [Error Boundary](#displaying-an-error-with-an-error-boundary) ile sarın.
1436
1291
1437
1292
```jsx
1438
1293
functionAlbums({ albumsPromise }) {
1439
1294
try {
1440
-
// ❌ Don't wrap `use` in try-catch
1295
+
// ❌ `use`’u try-catch içinde sarmayın
1441
1296
constalbums=use(albumsPromise);
1442
1297
} catch (e) {
1443
1298
return<p>Error</p>;
1444
1299
}
1445
1300
// ...
1446
1301
```
1447
1302
1448
-
Instead, wrap the componentin an Error Boundary:
1303
+
Bunun yerine, component’i bir Error Boundary ile sarın:
1449
1304
1450
1305
```jsx
1451
1306
functionAlbums({ albumsPromise }) {
1452
-
// ✅ Call `use` without try-catch
1307
+
// ✅ `use`’u try-catch olmadan çağırın
1453
1308
constalbums=use(albumsPromise);
1454
1309
// ...
1455
1310
```
1456
1311
1457
1312
```jsx
1458
-
// ✅ Use an Error Boundary to handle errors
1313
+
// ✅ Error’ları handle etmek için bir Error Boundary kullanın
1459
1314
<ErrorBoundary fallback={<p>Error</p>}>
1460
1315
<Albums albumsPromise={albumsPromise} />
1461
1316
</ErrorBoundary>
1462
1317
```
1463
1318
1464
1319
---
1465
1320
1466
-
### I'm getting a warning: "A component was suspended by an uncached promise" {/*uncached-promise-error*/}
1321
+
### Şu uyarıyı alıyorum: "A component was suspended by an uncached promise" {/*uncached-promise-error*/}
1467
1322
1468
-
The Promise passed to `use` is not cached, so React cannot reuse it across re-renders.
1323
+
`use`’a geçirilen Promise cache’lenmemiştir, bu yüzden React onu re-render’lar arasında yeniden kullanamaz.
1469
1324
1470
-
This commonly happens when calling `fetch` or an `async` function directly in render:
1325
+
Bu durum genellikle render sırasında doğrudan `fetch`veya bir`async` function çağrıldığında olur:
1471
1326
1472
1327
```js
1473
1328
functionAlbums() {
1474
-
// 🔴 This creates a new Promise on every render
1329
+
// 🔴 Bu, her render’da yeni bir Promise oluşturur
1475
1330
constalbums=use(fetch('/albums'));
1331
+
1476
1332
// ...
1477
1333
}
1478
1334
```
1479
1335
1480
-
To fix this, cache the Promise so the same instance is reused:
1336
+
Bunu düzeltmek için, aynı instance’ın yeniden kullanılmasını sağlayacak şekilde Promise’i cache’leyin:
1481
1337
1482
1338
```js
1483
-
// ✅ fetchData returns the same Promise for the same URL
1339
+
// ✅ fetchData aynı URL için aynı Promise’i döndürür
1484
1340
constalbums=use(fetchData('/albums'));
1485
1341
```
1486
1342
1487
-
See [caching Promises for Client Components](#caching-promises-for-client-components) for more details.
1488
-
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
1343
+
Daha fazla detay için [Client Components için Promise cache’leme](#caching-promises-for-client-components) bölümüne bakın.
0 commit comments