diff --git a/src/components/MDX/MDXComponents.tsx b/src/components/MDX/MDXComponents.tsx index 8d2073f1f..ef5912b09 100644 --- a/src/components/MDX/MDXComponents.tsx +++ b/src/components/MDX/MDXComponents.tsx @@ -113,16 +113,16 @@ function LearnMore({

- Ready to learn this topic? + Bu konuyu öğrenmeye hazır mısınız?

{children} {path ? ( - Read More + Devamını Oku ) : null} diff --git a/src/content/learn/adding-interactivity.md b/src/content/learn/adding-interactivity.md index 501c9f620..dba545647 100644 --- a/src/content/learn/adding-interactivity.md +++ b/src/content/learn/adding-interactivity.md @@ -20,11 +20,11 @@ Some things on the screen update in response to user input. For example, clickin -## Responding to events {/*responding-to-events*/} +## Olaylara tepki verme {/*responding-to-events*/} -React lets you add *event handlers* to your JSX. Event handlers are your own functions that will be triggered in response to user interactions like clicking, hovering, focusing on form inputs, and so on. +React, JSX'inize *olay yöneticileri* eklemenize olanak tanır. Olay yöneticileri (event handler); tıklama, üzerine gelme (hover), form girdilerine odaklanma gibi kullanıcı aksiyonlarına tepki vermek için tetiklenecek olan sahip olduğunuz fonksiyonlardır. -Built-in components like `
); @@ -68,7 +68,7 @@ button { margin-right: 10px; } -Read **[Responding to Events](/learn/responding-to-events)** to learn how to add event handlers. +Olay yöneticilerinin nasıl ekleneceğini öğrenmek için **[Olaylara Tepki Verme](/learn/responding-to-events)** bölümünü okuyun. diff --git a/src/content/learn/responding-to-events.md b/src/content/learn/responding-to-events.md index 782b6c0f1..741908651 100644 --- a/src/content/learn/responding-to-events.md +++ b/src/content/learn/responding-to-events.md @@ -1,24 +1,24 @@ --- -title: Responding to Events +title: Olaylara Tepki Verme --- -React lets you add *event handlers* to your JSX. Event handlers are your own functions that will be triggered in response to interactions like clicking, hovering, focusing form inputs, and so on. +React, JSX'inize olay yöneticileri eklemenize olanak tanır. Olay yöneticileri; tıklamak, fareyle üzerine gelmek ve form girdilerine odaklanmak gibi kullanıcı aksiyonlarına tepki verirken tetiklenecek olan fonksiyonlarınızdır. -* Different ways to write an event handler -* How to pass event handling logic from a parent component -* How events propagate and how to stop them +* Olay yöneticisi yazmanın farklı biçimleri +* Üst bileşenden (parent component) olay yönetimi mantığının nasıl iletileceği +* Olayların nasıl yayıldığı (propagation) ve nasıl durdurulacağı -## Adding event handlers {/*adding-event-handlers*/} +## Olay yöneticileri oluşturmak {/*adding-event-handlers*/} -To add an event handler, you will first define a function and then [pass it as a prop](/learn/passing-props-to-a-component) to the appropriate JSX tag. For example, here is a button that doesn't do anything yet: +Olay yöneticisi (event handler) oluşturmak için bir fonksiyon tanımlayıp uygun JSX etiketine [prop olarak iletirsiniz](/learn/passing-props-to-a-component). Örneğin, hiçbir şey yapmayan bir butonu ele alalım: @@ -26,7 +26,7 @@ To add an event handler, you will first define a function and then [pass it as a export default function Button() { return ( ); } @@ -34,23 +34,23 @@ export default function Button() { -You can make it show a message when a user clicks by following these three steps: +Kullanıcı düğmeye tıkladığında bir mesaj göstermek için aşağıdaki adımları izleyebilirsiniz: -1. Declare a function called `handleClick` *inside* your `Button` component. -2. Implement the logic inside that function (use `alert` to show the message). -3. Add `onClick={handleClick}` to the ` ); } @@ -62,77 +62,77 @@ button { margin-right: 10px; } -You defined the `handleClick` function and then [passed it as a prop](/learn/passing-props-to-a-component) to ` ); } function UploadButton() { return ( - ); } @@ -207,7 +207,7 @@ function UploadButton() { export default function Toolbar() { return (
- +
); @@ -220,22 +220,23 @@ button { margin-right: 10px; } -Here, the `Toolbar` component renders a `PlayButton` and an `UploadButton`: -- `PlayButton` passes `handlePlayClick` as the `onClick` prop to the `Button` inside. -- `UploadButton` passes `() => alert('Uploading!')` as the `onClick` prop to the `Button` inside. +`Toolbar` bileşeni, `PlayButton` ve `UploadButton` bileşenlerini render eder: -Finally, your `Button` component accepts a prop called `onClick`. It passes that prop directly to the built-in browser ` - ); @@ -268,9 +269,9 @@ button { margin-right: 10px; } -In this example, ` ); @@ -312,13 +313,13 @@ button { margin-right: 10px; } -Notice how the `App` component does not need to know *what* `Toolbar` will do with `onPlayMovie` or `onUploadImage`. That's an implementation detail of the `Toolbar`. Here, `Toolbar` passes them down as `onClick` handlers to its `Button`s, but it could later also trigger them on a keyboard shortcut. Naming props after app-specific interactions like `onPlayMovie` gives you the flexibility to change how they're used later. +Dikkat ederseniz `App` bileşeni, `Toolbar` bileşeninin `onPlayMovie` veya `onUploadImage` ile *ne* yapacağını bilmek zorunda değildir. Bu `Toolbar` bileşeninin implementasyon detayıdır. `Toolbar`, bu prop'ları `Button`'larına `onClick` olay yöneticisi olarak iletir. İleriki zamanlarda tıklama yerine klavye kısayoluyla da tetikletmek isteyebilirsiniz. Bileşenlerinizin prop'larını `onPlayMovie` gibi uygulamaya özgü etkileşimlere göre adlandırmak ileride kullanım biçimlerini değiştirme esnekliği sağlar. -## Event propagation {/*event-propagation*/} +## Olayların yayılması {/*event-propagation*/} -Event handlers will also catch events from any children your component might have. We say that an event "bubbles" or "propagates" up the tree: it starts with where the event happened, and then goes up the tree. +Olay yöneticileri aynı zamanda alt elementlerden gelen olayları da yakalar. Bu durum, olayların "kabarması" (bubble) ya da "yayılması" (propagate) olarak adlandırılır. Meydana geldiği yerde başlar ve DOM ağacında yukarı doğru ilerler. -This `
` contains two buttons. Both the `
` *and* each button have their own `onClick` handlers. Which handlers do you think will fire when you click a button? +Örnekteki `
` iki düğme içerir. Hem `
` *hem de* düğmeler kendi `onClick` yöneticilerine sahiptirler. Bir düğmeye tıkladığınızda hangi yöneticilerin tetikleneceğini düşünürsünüz? @@ -326,13 +327,13 @@ This `
` contains two buttons. Both the `
` *and* each button have their export default function Toolbar() { return (
{ - alert('You clicked on the toolbar!'); + alert('Araç çubuğuna tıkladın!'); }}> - -
); @@ -349,19 +350,19 @@ button { margin: 5px; } -If you click on either button, its `onClick` will run first, followed by the parent `
`'s `onClick`. So two messages will appear. If you click the toolbar itself, only the parent `
`'s `onClick` will run. +Bir düğmeye tıkladığınızda, önce kendi `onClick`'i çalışır sonrasında üst element olan `div`'in `onClick`'i çalışır. Bu sebeple iki mesaj belirir. Eğer araç çubuğuna tıklarsanız, yalnızca `div`'in `onClick`'i çalışır. -All events propagate in React except `onScroll`, which only works on the JSX tag you attach it to. +React'ta `onScroll` haricindeki tüm olaylar yayılır. `onScroll` ise sadece eklendiği JSX etiketi için çalışır. -### Stopping propagation {/*stopping-propagation*/} +### Yayılımı durdurmak {/*stopping-propagation*/} -Event handlers receive an **event object** as their only argument. By convention, it's usually called `e`, which stands for "event". You can use this object to read information about the event. +Olay yöneticileri argüman olarak yalnızca bir **olay nesnesi (event object)** alır. Genellikle olay teriminin İngilizce karşılığı "event"in kısaltılması olan `e` ile adlandırılırlar. Bu nesneyi kullanarak olay hakkındaki detaylara erişebilirsiniz. -That event object also lets you stop the propagation. If you want to prevent an event from reaching parent components, you need to call `e.stopPropagation()` like this `Button` component does: +Olay nesnesi ayrıca yayılımı durdurmanıza da imkan sağlar. Bir olayın üst bileşenlere erişmesini engellemek istiyorsanız, örnekteki `Button` bileşeninde olduğu gibi `e.stopPropagation()` çağırmalısınız. @@ -380,13 +381,13 @@ function Button({ onClick, children }) { export default function Toolbar() { return (
{ - alert('You clicked on the toolbar!'); + alert('Araç çubuğuna tıkladın!'); }}> - -
); @@ -403,43 +404,43 @@ button { margin: 5px; }
-When you click on a button: +Düğmelerden birisine tıkladığınızda: -1. React calls the `onClick` handler passed to `
``` -Each event propagates in three phases: +Her olay üç aşamada yayılır: -1. It travels down, calling all `onClickCapture` handlers. -2. It runs the clicked element's `onClick` handler. -3. It travels upwards, calling all `onClick` handlers. +1. Aşağıya doğru ilerleyecek şekilde tüm `onClickCapture` yöneticilerini çalıştırır. +2. Tıklanan elementin `onClick` yöneticisi çalıştırır. +3. Yukarı doğru ilerleyecek şekilde tüm `onClick` yöneticilerini çalıştırır. -Capture events are useful for code like routers or analytics, but you probably won't use them in app code. +Olayları yakalamak, yönlendirici (router) ya da analitik kodları için faydalıdır ancak muhtemelen uygulamanızda kullanmayacaksınız. -### Passing handlers as alternative to propagation {/*passing-handlers-as-alternative-to-propagation*/} +### Yayılıma alternatif olarak yöneticileri iletmek {/*passing-handlers-as-alternative-to-propagation*/} -Notice how this click handler runs a line of code _and then_ calls the `onClick` prop passed by the parent: +Örnekteki tıklama yöneticisinin önce bir kod satırını yürüttüğüne, _ardından_ üst bileşenden iletilen `onClick` prop'unu çağırdığına dikkat edin: ```js {4,5} function Button({ onClick, children }) { @@ -454,22 +455,22 @@ function Button({ onClick, children }) { } ``` -You could add more code to this handler before calling the parent `onClick` event handler, too. This pattern provides an *alternative* to propagation. It lets the child component handle the event, while also letting the parent component specify some additional behavior. Unlike propagation, it's not automatic. But the benefit of this pattern is that you can clearly follow the whole chain of code that executes as a result of some event. +Bu yöneticiye, üst bileşenin `onClick` olay yöneticisini çağırmadan önce, istediğiniz kadar kod ekleyebilirsiniz. Bu kalıp, yayılıma *alternatif* sağlar. Alt bileşenin olayı yönetmesine izin verirken, üst bileşenin ek davranışları belirlemesine olanak tanır. Yayılımın aksine otomatik değildir. Ancak bu kalıbın faydası, bir olay sonucunda yürütülen kod zincirinin tamamını net bir şekilde takip edebilmenizdir. -If you rely on propagation and it's difficult to trace which handlers execute and why, try this approach instead. +Eğer yayılıma güvenmiyorsanız ve hangi yöneticlerin neden çalıştığını takip etmekte zorlanıyorsanız bu yaklaşımı deneyin. -### Preventing default behavior {/*preventing-default-behavior*/} +### Varsayılan davranışı önlemek {/*preventing-default-behavior*/} -Some browser events have default behavior associated with them. For example, a `
` submit event, which happens when a button inside of it is clicked, will reload the whole page by default: +Bazı tarayıcı olayları, kendisine has varsayılan davranışlara sahiptir. Örneğin, ``'un gönderme (submit) olayı, içerisindeki düğmeye tıklandığında varsayılan olarak tüm sayfanın yeniden yüklenmesine neden olur: ```js export default function Signup() { return ( - alert('Submitting!')}> + alert('Gönderiliyor!')}> - + ); } @@ -481,7 +482,7 @@ button { margin-left: 5px; }
-You can call `e.preventDefault()` on the event object to stop this from happening: +Bu durumu önlemek için olay nesnesinden `e.preventDefault()` metodunu çağırabilirsiniz: @@ -490,10 +491,10 @@ export default function Signup() { return (
{ e.preventDefault(); - alert('Submitting!'); + alert('Gönderiliyor!'); }}> - +
); } @@ -505,28 +506,29 @@ button { margin-left: 5px; }
-Don't confuse `e.stopPropagation()` and `e.preventDefault()`. They are both useful, but are unrelated: -* [`e.stopPropagation()`](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation) stops the event handlers attached to the tags above from firing. -* [`e.preventDefault()` ](https://developer.mozilla.org/docs/Web/API/Event/preventDefault) prevents the default browser behavior for the few events that have it. +`e.stopPropagation()` ve `e.preventDefault()` metodlarını birbiriyle karıştırmayın. İkisi de yararlıdır ancak birbiriyle ilişkileri yoktur: + +* [`e.stopPropagation()`](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation), üstündeki etiketlere eklenen olay yöneticilerinin tetiklenmesini önler. +* [`e.preventDefault()` ](https://developer.mozilla.org/docs/Web/API/Event/preventDefault), bazı olayların sahip olduğu varsayılan tarayıcı davranışını önler. -## Can event handlers have side effects? {/*can-event-handlers-have-side-effects*/} +## Olay yöneticilerinin yan etkileri olabilir mi? {/*can-event-handlers-have-side-effects*/} -Absolutely! Event handlers are the best place for side effects. +Kesinlikle! Olay yöneticileri yan etkiler (side effect) için en iyi yerdir. -Unlike rendering functions, event handlers don't need to be [pure](/learn/keeping-components-pure), so it's a great place to *change* something—for example, change an input's value in response to typing, or change a list in response to a button press. However, in order to change some information, you first need some way to store it. In React, this is done by using [state, a component's memory.](/learn/state-a-components-memory) You will learn all about it on the next page. +Renderlama fonksiyonlarının aksine, olay yöneticilerinin [saf (pure)](/learn/keeping-components-pure) olması gerekmez. Bu sebeple bir şeyleri *değiştirmek* için güzel yerlerdir - örneğin, yazma eylemine tepki olarak girdi değerini değiştirmek veya düğmeye basma eylemine tepki olarak listeyi değiştirmek. Ancak, bilgiyi değiştirmek için öncelikle bir yerde saklamak gerekir. React'da bunu yapmak için [state, bileşen hafızası](/learn/state-a-components-memory) kullanabilirsiniz. Bununla ilgili tüm detayları bir sonraki sayfada öğreneceksiniz. -* You can handle events by passing a function as a prop to an element like ` ); } @@ -563,7 +565,7 @@ export default function LightSwitch() { -The problem is that ` ); } @@ -588,7 +590,7 @@ export default function LightSwitch() { -Alternatively, you could wrap the call into another function, like ` ); } @@ -615,11 +617,11 @@ export default function LightSwitch() { -#### Wire up the events {/*wire-up-the-events*/} +#### Olayları bağlayın {/*wire-up-the-events*/} -This `ColorSwitch` component renders a button. It's supposed to change the page color. Wire it up to the `onChangeColor` event handler prop it receives from the parent so that clicking the button changes the color. +`ColorSwitch` bileşeni bir düğme render eder ve tıklandığında sayfa rengini değiştirmesi beklenir. Düğmeye tıklandığında renk değiştirmek için üst bileşenden aldığınız `onChangeColor` olay yönetici prop'unu bileşene bağlayın. -After you do this, notice that clicking the button also increments the page click counter. Your colleague who wrote the parent component insists that `onChangeColor` does not increment any counters. What else might be happening? Fix it so that clicking the button *only* changes the color, and does _not_ increment the counter. +Düzeltmeyi yaptıktan sonra düğmeye yapılan tıklamaların beklenmedik şekilde sayfa tıklama sayacını da arttırdığına dikkat edin. Üst bileşeni yazan ekip arkadaşınız `onChangeColor` kodunda sayacın arttırılmadığı konusunda ısrar ediyor. Problemin sebebi başka ne olabilir? Düğmeye tıkladığınızda sayacın _artmaması_ için gerekli düzeltme yapın. Düğmenin *yalnızca* arkaplan rengini değiştirmesi beklenir. @@ -629,7 +631,7 @@ export default function ColorSwitch({ }) { return ( ); } @@ -663,7 +665,7 @@ export default function App() {

-

Clicks on the page: {clicks}

+

Sayfanın tıklanma sayısı: {clicks}

); } @@ -673,9 +675,9 @@ export default function App() { -First, you need to add the event handler, like ` ); } @@ -722,7 +724,7 @@ export default function App() {

-

Clicks on the page: {clicks}

+

Sayfa tıklanma sayısı: {clicks}

); } diff --git a/src/sidebarLearn.json b/src/sidebarLearn.json index 1db91c023..ebd6cd4d7 100644 --- a/src/sidebarLearn.json +++ b/src/sidebarLearn.json @@ -91,7 +91,7 @@ "tags": [], "routes": [ { - "title": "Responding to Events", + "title": "Olaylara Tepki Verme", "path": "/learn/responding-to-events" }, { @@ -186,7 +186,7 @@ }, { "title": "Removing Effect Dependencies", - "path": "/learn/removing-effect-dependencies" + "path": "/learn/removing-effect-dependencies" }, { "title": "Reusing Logic with Custom Hooks",