diff --git a/src/content/learn/index.md b/src/content/learn/index.md index b57655bc4..232a1c341 100644 --- a/src/content/learn/index.md +++ b/src/content/learn/index.md @@ -1,54 +1,54 @@ --- -title: Quick Start +title: Hızlı Başlangıç --- -Welcome to the React documentation! This page will give you an introduction to the 80% of React concepts that you will use on a daily basis. +React dokümantasyonuna hoşgeldiniz! Bu sayfa, günlük hayatınızda kullanacağınız React konseptlerinin %80'ine bir giriş yapacaktır. -- How to create and nest components -- How to add markup and styles -- How to display data -- How to render conditions and lists -- How to respond to events and update the screen -- How to share data between components +- Bileşenler nasıl yaratılır ve iç içe koyulur +- Biçimlendirme(markup) ve still nasıl eklenir +- Veri nasıl gösterilir +- Koşullar ve listeler nasıl render edilir +- Olaylara nasıl cevap verilir ve ekran güncellenir +- Bileşenler arasında veri nasıl paylaşılır -## Creating and nesting components {/*components*/} +## Bileşenleri yaratma ve iç içe koyma {/*components*/} -React apps are made out of *components*. A component is a piece of the UI (user interface) that has its own logic and appearance. A component can be as small as a button, or as large as an entire page. +React uygulamaları *bileşenlerden* oluşur. Bileşen kendi mantığına ve görünüşüne sahip bir UI (kullanıcı arayüzü) parçasıdır. Bir bileşen bir buton kadar küçük ya da tam bir sayfa kadar büyük olabilir. -React components are JavaScript functions that return markup: +React bileşenleri biçimlendirme(markup) döndüren JavaScript fonksiyonlarıdır: ```js function MyButton() { return ( - + ); } ``` -Now that you've declared `MyButton`, you can nest it into another component: +`MyButton` bileşenini bildirdiğinize göre, başka bir bileşen içine koyabilirsiniz: ```js {5} export default function MyApp() { return (
-

Welcome to my app

+

Uygulamama hoşgeldiniz

); } ``` -Notice that `` starts with a capital letter. That's how you know it's a React component. React component names must always start with a capital letter, while HTML tags must be lowercase. +``'un büyük harf ile başladığına dikkat edin. Bu onun bir React bileşeni olduğunu belirtir. HTML elemanları küçük harf ile başlamak zorundayken, React bileşenleri her zaman büyük harfle başlamak zorundadır. -Have a look at the result: +Sonuçlara bir göz atın: @@ -56,7 +56,7 @@ Have a look at the result: function MyButton() { return ( ); } @@ -64,7 +64,7 @@ function MyButton() { export default function MyApp() { return (
-

Welcome to my app

+

Uygulamama hoşgeldiniz

); @@ -73,49 +73,49 @@ export default function MyApp() {
-The `export default` keywords specify the main component in the file. If you're not familiar with some piece of JavaScript syntax, [MDN](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export) and [javascript.info](https://javascript.info/import-export) have great references. +`export default` anahtar kelimeleri dosyadaki ana bileşeni belirtir. Bazı JavaScript sözdizimlerine aşina değilseniz, [MDN](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export) ve [javascript.info](https://javascript.info/import-export) siteleri güzel referanslara sahiptir. -## Writing markup with JSX {/*writing-markup-with-jsx*/} +## JSX ile biçimlendirme yazma {/*writing-markup-with-jsx*/} -The markup syntax you've seen above is called *JSX*. It is optional, but most React projects use JSX for its convenience. All of the [tools we recommend for local development](/learn/installation) support JSX out of the box. +Yukarıda gördüğünüz biçimlendirme sözdizimine *JSX* denir. Opsiyoneldir, ancak çoğu React projesi kolaylığından dolayı JSX kullanır. [Yerel geliştirme için tavsiye ettiğimiz tüm araçlar](/learn/installation) JSX'i desteklemektedir. -JSX is stricter than HTML. You have to close tags like `
`. Your component also can't return multiple JSX tags. You have to wrap them into a shared parent, like a `
...
` or an empty `<>...` wrapper: +JSX, HTML'den daha katıdır. Elemanları `
` gibi kapatmak zorundasınızdır. Aynı zamanda bileşeniniz birden fazla JSX elemanı döndüremez. Döndürmek isteğiniz elemanları `
...
` veya boş `<>...` gibi ortak bir üst eleman içine koymanız gerekmektedir: ```js {3,6} function AboutPage() { return ( <> -

About

-

Hello there.
How do you do?

+

Hakkında

+

Selamlar.
Nasılsın?

); } ``` -If you have a lot of HTML to port to JSX, you can use an [online converter.](https://transform.tools/html-to-jsx) +JSX'e aktaracak çok fazla HTML'iniz varsa, [çevrimiçi bir dönüştürücü](https://transform.tools/html-to-jsx) kullanabilirsiniz. -## Adding styles {/*adding-styles*/} +## Stil ekleme {/*adding-styles*/} -In React, you specify a CSS class with `className`. It works the same way as the HTML [`class`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class) attribute: +React'te, bir CSS class'ı belirtmek için `className` kullanılır. HTML [`class`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class) özelliği ile aynı şekilde çalışmaktadır: ```js ``` -Then you write the CSS rules for it in a separate CSS file: +Daha sonra CSS kurallarını ayrı bir CSS dosyasında yazarsınız: ```css -/* In your CSS */ +/* CSS dosyanızda */ .avatar { border-radius: 50%; } ``` -React does not prescribe how you add CSS files. In the simplest case, you'll add a [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) tag to your HTML. If you use a build tool or a framework, consult its documentation to learn how to add a CSS file to your project. +React, CSS dosyalarınız nasıl ekleyeceğinizi belirtmez. En basit durumda, HTML'inize bir [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) elemanı eklersiniz. Bir derleme aracı veya çatı kullanıyorsanız, projenize nasıl CSS dosyası ekleyeceğinizi öğrenmek için dokümantasyonlara başvurun. -## Displaying data {/*displaying-data*/} +## Veri gösterme {/*displaying-data*/} -JSX lets you put markup into JavaScript. Curly braces let you "escape back" into JavaScript so that you can embed some variable from your code and display it to the user. For example, this will display `user.name`: +JSX, biçimlendirmeyi JavaScript'e dönüştürmenizi sağlar. Süslü parantezler, kodunuzdaki bazı değişkenleri gömebilmeniz ve bu değişkenleri kullanıcıya gösterebilmeniz için JavaScript'e "geri kaçmanızı" sağlar. Örneğin, bu kod `user.name`'i gösterecktir: ```js {3} return ( @@ -125,7 +125,7 @@ return ( ); ``` -You can also "escape into JavaScript" from JSX attributes, but you have to use curly braces *instead of* quotes. For example, `className="avatar"` passes the `"avatar"` string as the CSS class, but `src={user.imageUrl}` reads the JavaScript `user.imageUrl` variable value, and then passes that value as the `src` attribute: +Ayrıca JSX özelliklerinden "JavaScript'e kaçabilirsiniz" ancak tırnak işareti *yerine* süslü parentezleri kullanmak zorundasınızdır. Örneğin, `className="avatar"` ifadesi `"avatar"` string'ini CSS sınıfı olarak iletir ancak `src={user.imageUrl}` ifadesi `user.imageUrl` JavaScript değişken değerini okur ve `src` özelliği olarak o değeri iletir: ```js {3,4} return ( @@ -136,7 +136,7 @@ return ( ); ``` -You can put more complex expressions inside the JSX curly braces too, for example, [string concatenation](https://javascript.info/operators#string-concatenation-with-binary): +JSX süslü parentezleri içine daha karmaşık ifadeler koyabilirsiniz, örneğin, [string birleştirme](https://javascript.info/operators#string-concatenation-with-binary): @@ -177,11 +177,11 @@ export default function Profile() { -In the above example, `style={{}}` is not a special syntax, but a regular `{}` object inside the `style={ }` JSX curly braces. You can use the `style` attribute when your styles depend on JavaScript variables. +Yukarıdaki örnekte `style={{}}` ifadesi özel bir sözdizimi değildir. `style={ }` JSX süslü parantezleri içinde sıradan bir `{}` nesnesidir. `style` özelliğini stilleriniz JavaScript değişkenlerine bağlı olduğunda kullanabilirsiniz. -## Conditional rendering {/*conditional-rendering*/} +## Koşullu render etme {/*conditional-rendering*/} -In React, there is no special syntax for writing conditions. Instead, you'll use the same techniques as you use when writing regular JavaScript code. For example, you can use an [`if`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else) statement to conditionally include JSX: +React'te, koşullu ifadeleri yazmanın özel bir sözdizimi yoktur. Onun yerine, sıradan JavaScript kodu yazarken kullandığınız aynı teknikleri kullanacaksınız. Örneğin, [`if`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else) ifadesini, koşullu olarak JSX'i dahil etmek için kullanabilirsiniz: ```js let content; @@ -197,7 +197,7 @@ return ( ); ``` -If you prefer more compact code, you can use the [conditional `?` operator.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) Unlike `if`, it works inside JSX: +Daha kompakt bir kod tercih ediyorsanız [koşullu `?` operatörünü](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) kullanabilirsiniz. `if` ifadesinin aksine, JSX'in içinde çalışır: ```js
@@ -209,7 +209,7 @@ If you prefer more compact code, you can use the [conditional `?` operator.](htt
``` -When you don't need the `else` branch, you can also use a shorter [logical `&&` syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND#short-circuit_evaluation): +`else` ifadesine ihtiyacınız olmadığında, daha kısa olan [`&&` sözdizimini](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND#short-circuit_evaluation) de kullanabilirsiniz: ```js
@@ -217,23 +217,23 @@ When you don't need the `else` branch, you can also use a shorter [logical `&&`
``` -All of these approaches also work for conditionally specifying attributes. If you're unfamiliar with some of this JavaScript syntax, you can start by always using `if...else`. +Tüm bu yaklaşımlar koşullu olarak özelliklerin belirlenmesi için de çalışır. Eğer bu JavaScript sözdizimlerinden bazılarına yabancıysanız, her zaman `if...else` ifadelerini kullanarak başlayabilirsiniz. -## Rendering lists {/*rendering-lists*/} +## Listeleri render etme {/*rendering-lists*/} -You will rely on JavaScript features like [`for` loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for) and the [array `map()` function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) to render lists of components. +Bileşen listeleri oluşturmak için [`for` döngüsü](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for) ve [dizi `map()` fonksiyonu](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) gibi JavaScript özelliklerini kullanacaksınız. -For example, let's say you have an array of products: +Örneğin, bir dizi ürün listesine sahip olduğunuzu düşünelim: ```js const products = [ - { title: 'Cabbage', id: 1 }, - { title: 'Garlic', id: 2 }, - { title: 'Apple', id: 3 }, + { title: 'Lahana', id: 1 }, + { title: 'Sarımsak', id: 2 }, + { title: 'Elma', id: 3 }, ]; ``` -Inside your component, use the `map()` function to transform an array of products into an array of `
  • ` items: +Bileşeniniz içinde `map()` fonksiyonunu kullanarak bir dizi ürünü bir dizi `
  • ` öğesine dönüştürün: ```js const listItems = products.map(product => @@ -247,15 +247,15 @@ return ( ); ``` -Notice how `
  • ` has a `key` attribute. For each item in a list, you should pass a string or a number that uniquely identifies that item among its siblings. Usually, a key should be coming from your data, such as a database ID. React uses your keys to know what happened if you later insert, delete, or reorder the items. +`
  • `'nin `key` özelliğine sahip olduğuna dikkat edin. Listedeki her bir öğe için, o öğeyi kardeşlerinden ayırt edecek bir string ya da sayı iletmenizi gereklidir. Genellikle, veritabanı ID'si gibi bir anahtar veriniz ile geliyor olmalıdır. React, daha sonra eğer yeni veri girerseniz, bir veriyi silerseniz ya da yeniden sıralarsanız ne olacağını bilmek için bu anahtarları kullanır. ```js const products = [ - { title: 'Cabbage', isFruit: false, id: 1 }, - { title: 'Garlic', isFruit: false, id: 2 }, - { title: 'Apple', isFruit: true, id: 3 }, + { title: 'Lahana', isFruit: false, id: 1 }, + { title: 'Sarımsak', isFruit: false, id: 2 }, + { title: 'Elma', isFruit: true, id: 3 }, ]; export default function ShoppingList() { @@ -278,37 +278,37 @@ export default function ShoppingList() { -## Responding to events {/*responding-to-events*/} +## Olaylara cevap verme {/*responding-to-events*/} -You can respond to events by declaring *event handler* functions inside your components: +Bileşenlerinizin içinde *olay yöneticisi* fonksiyonları bildirerek olaylara cevap verebilirsiniz: ```js {2-4,7} function MyButton() { function handleClick() { - alert('You clicked me!'); + alert('Bana tıkladın!'); } return ( ); } ``` -Notice how `onClick={handleClick}` has no parentheses at the end! Do not _call_ the event handler function: you only need to *pass it down*. React will call your event handler when the user clicks the button. +`onClick={handleClick}` ifadesinin sonunda parantez olmadığına dikkat edin! Olay yöneticisi fonksiyonu _çağırmayın_: bu fonksiyonu sadece *aşağıya iletmelisiniz*. React, kullanıcı butona tıkladığı zaman olay yöneticisini çağıracaktır. -## Updating the screen {/*updating-the-screen*/} +## Ekranı güncelleme {/*updating-the-screen*/} -Often, you'll want your component to "remember" some information and display it. For example, maybe you want to count the number of times a button is clicked. To do this, add *state* to your component. +Sık sık, bileşeninizin bazı bilgileri ekran göstermek için "hatırlamasını" isteyeceksiniz. Örneğin, bir butona kaç defa tıklandığını takip etmek istiyorsunuz. Bunu yapmak için bileşeninize *state* ekleyin. -First, import [`useState`](/reference/react/useState) from React: +İlk olarak, React'ten [`useState`](/reference/react/useState) çağırın: ```js import { useState } from 'react'; ``` -Now you can declare a *state variable* inside your component: +Şimdi bileşeniniz içinde bir *state değişkeni* bildirin: ```js function MyButton() { @@ -316,9 +316,9 @@ function MyButton() { // ... ``` -You’ll get two things from `useState`: the current state (`count`), and the function that lets you update it (`setCount`). You can give them any names, but the convention is to write `[something, setSomething]`. +`useState`'ten iki şey alacaksınız: mevcut state (`count`) ve state'i güncellemenizi sağlayan (`setCount`). Burada istediğiniz isimleri verebilirsiniz ancak yaygın kullanış `[something, setSomething]` şeklindedir. -The first time the button is displayed, `count` will be `0` because you passed `0` to `useState()`. When you want to change state, call `setCount()` and pass the new value to it. Clicking this button will increment the counter: +Buton ilk defa görüntülendiğinde `count` değeri `0` olacaktır çünkü `useState()`'e `0` değerini ilettiniz. State'i değiştirmek istediğinizde, `setCount()`'u çağırın ve yeni değeri iletin. Bu butona tıklamak sayacı artıcaktır: ```js {5} function MyButton() { @@ -330,15 +330,15 @@ function MyButton() { return ( ); } ``` -React will call your component function again. This time, `count` will be `1`. Then it will be `2`. And so on. +React bileşen fonksiyonunuzu yeniden çağıracaktır. Bu sefer `count` değeri `1` olacaktır. Daha sonra `2`. Ve bu böyle devam edecektir. -If you render the same component multiple times, each will get its own state. Click each button separately: +Aynı bileşeni birden fazla render edersiniz, her biri kendi state'ine sahip olacaktır. Her butona ayrı ayrı tıklayın: @@ -348,7 +348,7 @@ import { useState } from 'react'; export default function MyApp() { return (
    -

    Counters that update separately

    +

    Ayrı olarak güncellenen sayaçlar

    @@ -364,7 +364,7 @@ function MyButton() { return ( ); } @@ -379,59 +379,59 @@ button {
    -Notice how each button "remembers" its own `count` state and doesn't affect other buttons. +Her bir butonun kendi `count` state'ini "hatırladığına" ve diğerlerini etkilemediğine dikkat edin. -## Using Hooks {/*using-hooks*/} +## Hook kullanmak {/*using-hooks*/} -Functions starting with `use` are called *Hooks*. `useState` is a built-in Hook provided by React. You can find other built-in Hooks in the [API reference.](/reference/react) You can also write your own Hooks by combining the existing ones. +`use` ile başlayan fonksiyonlara *Hook* denir. `useState`, React tarafından sağlanan bir Hook'tur. [API referansında](/reference/react) diğer yerleşik Hook'ları bulabilirsiniz. Aynı zamanda var olan Hook'ları kullanarak kendi Hook'unuzu da yazabilirsiniz. -Hooks are more restrictive than other functions. You can only call Hooks *at the top* of your components (or other Hooks). If you want to use `useState` in a condition or a loop, extract a new component and put it there. +Hook'lar diğer fonksiyonlara göre daha kısıtlayıcıdırlar. Hook'ları bileşeninizin sadece *en üst seviyesinde* çağırabilirsiniz (ya da diğer Hook'ları). Eğer `useState`'i bir koşul ya da döngü içinde kullanmak istiyorsanız, yeni bir bileşen oluşturun ve onun içine koyun. -## Sharing data between components {/*sharing-data-between-components*/} +## Bileşenler arasında veri paylaşma {/*sharing-data-between-components*/} -In the previous example, each `MyButton` had its own independent `count`, and when each button was clicked, only the `count` for the button clicked changed: +Bir önceki örnekte, her bir `MyButton` bileşeni kendi bağımsız `count` değerine sahipti ve her bir butona tıklandığında, sadece tıklanan butonun `count` değeri değişmekteydi: - + -Initially, each `MyButton`'s `count` state is `0` +Başlangıçta, her bir `MyButton`'un `count` state'i `0`'dır. - + -The first `MyButton` updates its `count` to `1` +İlk `MyButton` bileşeni `count` değerini `1` ile değiştirir. -However, often you'll need components to *share data and always update together*. +Ancak çoğu zaman bileşenlerin *veriyi paylaşması ve her zaman beraber güncellemesini* isteriz. -To make both `MyButton` components display the same `count` and update together, you need to move the state from the individual buttons "upwards" to the closest component containing all of them. +Her iki `MyButton` bileşeninin aynı `count` değerini göstermesi ve aynı anda güncellenmesi için state'i bireysel butonlardan "yukarı", hepsini içeren en yakın bileşene taşımanız gerekmektedir. -In this example, it is `MyApp`: +Bu örnekte hepsini içeren bileşen `MyApp`: - + -Initially, `MyApp`'s `count` state is `0` and is passed down to both children +Başlangıçta, `MyApp`'in `count` state değeri `0`'dır ve her iki alt elemana iletilmiştir. - + -On click, `MyApp` updates its `count` state to `1` and passes it down to both children +Tıklama ile, `MyApp` kendi `count` state'ini `1` ile günceller ve iki alt elemana iletir -Now when you click either button, the `count` in `MyApp` will change, which will change both of the counts in `MyButton`. Here's how you can express this in code. +Şimdi hangi butona tıklarsanız tıklayın, `MyApp` içindeki `count` değişkeni değişecektir, ki bu da her iki `MyButton` bileşeni içideki count değerini güncelleyecektir. Bu anlattıklarımızı kod halinde nasıl göstereceğimizi aşağıda görebiliriz. -First, *move the state up* from `MyButton` into `MyApp`: +İlk olarak, state'i `MyButton`'dan `MyApp`' bileşenine olacak şekilde *yukarı taşıyın:* ```js {2-6,18} export default function MyApp() { @@ -443,7 +443,7 @@ export default function MyApp() { return (
    -

    Counters that update separately

    +

    Birbirinden ayrı güncellenen sayaçlar

    @@ -451,12 +451,12 @@ export default function MyApp() { } function MyButton() { - // ... we're moving code from here ... + // ... kodu buradan taşıyoruz ... } ``` -Then, *pass the state down* from `MyApp` to each `MyButton`, together with the shared click handler. You can pass information to `MyButton` using the JSX curly braces, just like you previously did with built-in tags like ``: +Daha sonra, state'i `MyApp` bileşeninden her bir `MyButton` bileşenine ortak tıklama yönetecisi ile birlikte *aşağı doğru iletin.* `MyButton` bileşenine bilgiyi JSX süslü parantezleri ile iletebilirsiniz, tıpkı yerleşik `` elementlerinde yaptığımız gibi: ```js {11-12} export default function MyApp() { @@ -468,7 +468,7 @@ export default function MyApp() { return (
    -

    Counters that update together

    +

    Beraber güncellenen sayaçlar

    @@ -476,21 +476,21 @@ export default function MyApp() { } ``` -The information you pass down like this is called _props_. Now the `MyApp` component contains the `count` state and the `handleClick` event handler, and *passes both of them down as props* to each of the buttons. +Bu şekilde aşağıya doğru ilettiğiniz bilgilere _prop_ denmektedir. Artık `MyApp` bileşeni `count` state'ini ve `handleClick` olay yöneticisini içerir ve her bir butona *bu ikisini prop olarak aşağı doğru iletir.* -Finally, change `MyButton` to *read* the props you have passed from its parent component: +Son olarak, `MyButton` bileşenini üst bileşenden ilettiğiniz prop'ları *okuyacak* şekilde düzenleyin: ```js {1,3} function MyButton({ count, onClick }) { return ( ); } ``` -When you click the button, the `onClick` handler fires. Each button's `onClick` prop was set to the `handleClick` function inside `MyApp`, so the code inside of it runs. That code calls `setCount(count + 1)`, incrementing the `count` state variable. The new `count` value is passed as a prop to each button, so they all show the new value. This is called "lifting state up". By moving state up, you've shared it between components. +Butona tıkladığınız zaman, `onClick` yöneticisi çalışır. Her bir butonun `onClick` prop'u `MyApp` bileşeni içindeki `handleClick` fonksiyonuna ayarlanmıştır ve fonksiyon içindeki kod çalışır. Bu kod `setCount(count + 1)` ifadesini çağırır ve `count` state değişkenini artırır. Yeni `count` değeri her bir butona prop olarak iletilir, böylelikle hepsi yeni değeri gösterir. Buna "state'in yukarı kaldırılması" denir. State'i yukarı kaldırarak, bileşenler arasında paylaşmış oldunuz. @@ -506,7 +506,7 @@ export default function MyApp() { return (
    -

    Counters that update together

    +

    Beraber güncellenen sayaçlar

    @@ -516,7 +516,7 @@ export default function MyApp() { function MyButton({ count, onClick }) { return ( ); } @@ -533,6 +533,6 @@ button { ## Next Steps {/*next-steps*/} -By now, you know the basics of how to write React code! +Artık React kodunu yazmanın temellerini biliyorsunuz! -Check out the [Tutorial](/learn/tutorial-tic-tac-toe) to put them into practice and build your first mini-app with React. +[Tutorial](/learn/tutorial-tic-tac-toe) sayfasına giderek öğrendiklerinizi pratik edebilir ve ilk mini React uygulamanızı yapabilirsiniz.