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
Add `'use server'`at the top of an async function body to mark the function as callable by the client. We call these functions [_Server Functions_](/reference/rsc/server-functions).
27
+
Bir async fonksiyonunun başına `'use server'`ekleyerek fonksiyonu istemci tarafından çağrılabilir hale getirin. Bu fonksiyonlara [_Server Functions_](/reference/rsc/server-functions) denir.
28
28
29
29
```js {2}
30
30
asyncfunctionaddToCart(data) {
@@ -33,38 +33,38 @@ async function addToCart(data) {
33
33
}
34
34
```
35
35
36
-
When calling a Server Function on the client, it will make a network request to the server that includes a serialized copy of any arguments passed. If the Server Function returns a value, that value will be serialized and returned to the client.
36
+
Bir Sunucu Fonksiyon'u istemciden çağırdığınızda, geçilen tüm argümanların serileştirilmiş bir kopyasını içeren bir ağ isteği sunucuya yapılır. Eğer Sunucu Fonksiyon bir değer dönerse, bu değer serileştirilir ve istemciye geri gönderilir.
37
37
38
-
Instead of individually marking functions with `'use server'`, you can add the directive to the top of a file to mark all exports within that file as Server Functions that can be used anywhere, including imported in client code.
38
+
Fonksiyonları tek tek `'use server'` ile işaretlemek yerine, bir dosyanın başına yönergeyi ekleyebilirsiniz, böylece o dosyadaki tüm export'lar, istemci kodunda da kullanılabilen Sunucu Fonksiyon'lar olarak işaretlenir.
39
39
40
-
#### Caveats {/*caveats*/}
41
-
*`'use server'`must be at the very beginning of their function or module; above any other code including imports (comments above directives are OK). They must be written with single or double quotes, not backticks.
42
-
*`'use server'`can only be used in server-side files. The resulting Server Functions can be passed to Client Components through props. See supported [types for serialization](#serializable-parameters-and-return-values).
43
-
*To import a Server Functions from [client code](/reference/rsc/use-client), the directive must be used on a module level.
44
-
*Because the underlying network calls are always asynchronous, `'use server'`can only be used on async functions.
45
-
*Always treat arguments to Server Functions as untrusted input and authorize any mutations. See [security considerations](#security).
46
-
*Server Functions should be called in a [Transition](/reference/react/useTransition). Server Functions passed to [`<form action>`](/reference/react-dom/components/form#props)or[`formAction`](/reference/react-dom/components/input#props)will automatically be called in a transition.
47
-
*Server Functions are designed for mutations that update server-side state; they are not recommended for data fetching. Accordingly, frameworks implementing Server Functions typically process one action at a time and do not have a way to cache the return value.
40
+
#### Uyarılar {/*caveats*/}
41
+
*`'use server'`fonksiyonlarının veya modüllerinin başında, diğer kodlardan (imports dahil) önce olmalıdır (yönergelerden önceki yorumlar kabul edilir). Tek tırnak veya çift tırnak ile yazılmalıdır, ters tırnak kullanılamaz.
42
+
*`'use server'`yalnızca sunucu tarafı dosyalarında kullanılabilir. Ortaya çıkan Sunucu Fonksiyon'lar, Sunucu Bileşen'lere prop'lar aracılığıyla iletilebilir. Desteklenen [serileştirme türlerine](#serializable-parameters-and-return-values) bakın.
43
+
*Bir Sunucu Fonksiyon'ı [istemci kodu](/reference/rsc/use-client) içinden içe aktarmak için, yönerge modül seviyesinde kullanılmalıdır.
44
+
*Altta yatan ağ çağrıları her zaman asenkron olduğu için, `'use server'`yalnızca async fonksiyonlarda kullanılabilir.
45
+
*Sunucu Fonksiyon'lara geçirilen argümanları her zaman güvenilmeyen girişler olarak ele alın ve herhangi bir değişiklik yapmadan önce yetkilendirme yapın. [Güvenlik önlemleri](#security) için bakın.
46
+
*Sunucu Fonksiyon'lar bir [Transition](/reference/react/useTransition) içinde çağrılmalıdır. [`<form action>`](/reference/react-dom/components/form#props)veya[`formAction`](/reference/react-dom/components/input#props)ile geçirilen Sunucu Fonksiyon'lar otomatik olarak bir geçiş içinde çağrılacaktır.
47
+
*Sunucu Fonksiyon'lar, sunucu tarafı durumu güncelleyen değişiklikler için tasarlanmıştır; veri çekme işlemleri için önerilmezler. Bu nedenle, Sunucu Fonksiyon'ları uygulayan framework'ler genellikle her seferinde bir işlemi işler ve dönüş değerini önbelleğe almak için bir yöntem sunmazlar.
48
48
49
49
### Güvenlikle ilgili hususlar {/*security*/}
50
50
51
-
Arguments to Server Functions are fully client-controlled. For security, always treat them as untrusted input, and make sure to validate and escape arguments as appropriate.
51
+
Sunucu Fonksiyon'lara geçirilen argümanlar tamamen istemci tarafından kontrol edilir. Güvenlik için, her zaman bunları güvenilmeyen girişler olarak ele alın ve argümanları uygun şekilde doğrulayın ve kaçış işlemi uygulayın.
52
52
53
-
In any Server Function, make sure to validate that the logged-in user is allowed to perform that action.
53
+
Herhangi bir Sunucu Fonksiyonu içinde, giriş yapmış kullanıcının bu işlemi gerçekleştirmeye yetkili olduğundan emin olun.
54
54
55
55
<Wip>
56
56
57
-
To prevent sending sensitive data from a Server Function, there are experimental taint APIs to prevent unique values and objects from being passed to client code.
57
+
Bir Sunucu Fonksiyonun'dan hassas veri gönderimini önlemek için, istemci koduna benzersiz değerlerin ve nesnelerin iletilmesini engellemek amacıyla deneysel taint API'leri mevcuttur.
58
58
59
59
Bkz. [experimental_taintUniqueValue](/reference/react/experimental_taintUniqueValue) ve [experimental_taintObjectReference](/reference/react/experimental_taintObjectReference).
60
60
61
61
</Wip>
62
62
63
63
### Serileştirilebilir bağımsız değişkenler ve dönüş değerleri {/*serializable-parameters-and-return-values*/}
64
64
65
-
Since client code calls the Server Function over the network, any arguments passed will need to be serializable.
65
+
İstemci kodu, Sunucu Fonksiyon'u ağ üzerinden çağırdığı için, geçirilen tüm argümanların serileştirilebilir olması gerekir.
66
66
67
-
Here are supported types for Server Function arguments:
67
+
İşte Sunucu Fonksiyon argümanları için desteklenen türler:
* Plain [objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object): those created with [object initializers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer), with serializable properties
* Objects that are instances of any class (other than the built-ins mentioned) or objects with [a null prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects)
94
-
* Symbols not registered globally, ex. `Symbol('my new symbol')`
95
-
* Events from event handlers
96
-
89
+
Özellikle, bunlar desteklenmez:
90
+
* React elemanları veya [JSX](/learn/writing-markup-with-jsx)
91
+
* Fonksiyonlar, bileşen fonksiyonları veya Sunucu Fonksiyon olmayan diğer tüm fonksiyonlar dahil
* Herhangi bir sınıfın örnekleri olan nesneler (bahsedilen yerleşik sınıflar dışında) veya [null prototipi olan nesneler](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects)
94
+
* Küresel olarak kaydedilmemiş semboller, örneğin `Symbol('my new symbol')`
95
+
* Olay yöneticilerinden gelen olaylar
97
96
98
97
Desteklenen serileştirilebilir dönüş değerleri, bir sınır İstemci Bileşeni için [serileştirilebilir proplar](/reference/rsc/use-client#passing-props-from-server-to-client-components) ile aynıdır.
The most common use case of Server Functions will be calling functions that mutate data. On the browser, the [HTML form element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) is the traditional approach for a user to submit a mutation. With React Server Components, React introduces first-class support for Server Functions as Actions in [forms](/reference/react-dom/components/form).
105
+
Sunucu Fonksiyon'ların en yaygın kullanım senaryosu, veri üzerinde değişiklik yapan fonksiyonları çağırmaktır. Tarayıcıda, [HTML form elemanı](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form), bir kullanıcının bir değişiklik göndermesi için geleneksel yaklaşımdır. React Sunucu Bileşenleri ile React, [formlarda](/reference/react-dom/components/form) Sunucu Fonksiyon'lar için birinci sınıf destek sunar.
107
106
108
-
Here is a form that allows a user to request a username.
107
+
İşte bir kullanıcının bir kullanıcı adı talep etmesine izin veren bir form.
109
108
110
109
```js [[1, 3, "formData"]]
111
110
// App.js
@@ -126,15 +125,15 @@ export default function App() {
126
125
}
127
126
```
128
127
129
-
In this example `requestUsername` is a Server Function passed to a `<form>`. When a user submits this form, there is a network request to the server function `requestUsername`. When calling a Server Function in a form, React will supply the form's <CodeStepstep={1}>[FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)</CodeStep> as the first argument to the Server Function.
128
+
Bu örnekte `requestUsername`, bir `<form>`'a geçirilen bir Sunucu Fonksiyon'dır. Bir kullanıcı bu formu gönderdiğinde, `requestUsername` sunucu fonksiyonuna yapılan bir ağ isteği gerçekleşir. Bir Sunucu Fonksiyon'ı form içinde çağırırken, React, formun <CodeStepstep={1}>[FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)</CodeStep>'sini birinci argüman olarak Sunucu Fonksiyon'a iletecektir.
130
129
131
-
By passing a Server Function to the form `action`, React can [progressively enhance](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement) the form. This means that forms can be submitted before the JavaScript bundle is loaded.
130
+
Bir Sunucu Fonksiyon'ı form `action`'ına geçirerek, React formu [kademeli olarak iyileştirebilir](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement). Bu, formların JavaScript paketi yüklenmeden önce gönderilebileceği anlamına gelir.
132
131
133
132
#### Formlarda dönüş değerlerini işleme {/*handling-return-values*/}
134
133
135
134
Kullanıcı adı istek formunda, bir kullanıcı adının mevcut olmaması ihtimali olabilir. `requestUsername` bize başarısız olup olmadığını söylemelidir.
136
135
137
-
To update the UI based on the result of a Server Function while supporting progressive enhancement, use [`useActionState`](/reference/react/useActionState).
136
+
Sunucu Fonksiyonu sonucuna dayalı olarak UI'yı güncellemek ve kademeli iyileştirmeyi desteklemek için, [`useActionState`](/reference/react/useActionState) kullanın.
138
137
139
138
```js
140
139
// requestUsername.js
@@ -172,14 +171,13 @@ function UsernameForm() {
172
171
}
173
172
```
174
173
175
-
Note that like most Hooks, `useActionState` can only be called in <CodeStepstep={1}>[client code](/reference/rsc/use-client)</CodeStep>.
176
-
Çoğu Hook gibi `useActionState`in de yalnızca <CodeStepstep={1}>[client code](/reference/rsc/use-client)</CodeStep> içinde çağrılabileceğini unutmayın.
174
+
Not: Diğer çoğu Hook gibi `useActionState`in de yalnızca <CodeStepstep={1}>[client code](/reference/rsc/use-client)</CodeStep> içinde çağrılabileceğini unutmayın.
177
175
178
-
### Calling a Server Function outside of `<form>` {/*calling-a-server-function-outside-of-form*/}
176
+
### `<form>` dışında bir Sunucu Fonksiyon'u çağırma {/*calling-a-server-function-outside-of-form*/}
179
177
180
-
Server Functions are exposed server endpoints and can be called anywhere in client code.
178
+
Sunucu Fonksiyon'lar, sunucu uç noktalarıdır ve istemci kodunda her yerde çağrılabilir.
181
179
182
-
When using a Server Function outside a [form](/reference/react-dom/components/form), call the Server Function in a [Transition](/reference/react/useTransition), which allows you to display a loading indicator, show [optimistic state updates](/reference/react/useOptimistic), and handle unexpected errors. Forms will automatically wrap Server Functions in transitions.
180
+
Bir Sunucu Fonksiyon'u bir [form](/reference/react-dom/components/form) dışında kullanırken, Sunucu Fonksiyon'u bir [Transition](/reference/react/useTransition) içinde çağırın, bu sayede yükleme göstergesi gösterebilir, [iyimser durum güncellemeleri](/reference/react/useOptimistic) yapabilir ve beklenmeyen hataları yönetebilirsiniz. Formlar, otomatik olarak Sunucu Fonksiyon'ları geçişler içinde sarar.
183
181
184
182
```js {9-12}
185
183
importincrementLikefrom'./actions';
@@ -216,4 +214,4 @@ export default async function incrementLike() {
216
214
}
217
215
```
218
216
219
-
To read a Server Function return value, you'll need to `await`the promise returned.
217
+
Bir Sunucu Fonksiyon dönüş değerini okumak için, döndürülen promise'i `await`etmeniz gerekecek.
0 commit comments