From dd5812ed3b0284e9f0797ff559150f1785652f03 Mon Sep 17 00:00:00 2001 From: halilatilla Date: Thu, 27 Apr 2023 09:23:59 +0300 Subject: [PATCH 1/3] Translate `createContext` Translate `createContext` --- src/content/reference/react/createContext.md | 74 ++++++++++---------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/content/reference/react/createContext.md b/src/content/reference/react/createContext.md index ff9032aac..b4fdb4db7 100644 --- a/src/content/reference/react/createContext.md +++ b/src/content/reference/react/createContext.md @@ -4,7 +4,7 @@ title: createContext -`createContext` lets you create a [context](/learn/passing-data-deeply-with-context) that components can provide or read. +`createContext`, bileşenlerin sağlayabileceği veya okuyabileceği bir [context](/learn/passing-data-deeply-with-context) oluşturmanızı sağlar. ```js const SomeContext = createContext(defaultValue) @@ -16,11 +16,11 @@ const SomeContext = createContext(defaultValue) --- -## Reference {/*reference*/} +## Referans {/*reference*/} ### `createContext(defaultValue)` {/*createcontext*/} -Call `createContext` outside of any components to create a context. +Bir context oluşturmak için bileşenlerin dışından `createContext`'i çağırın. ```js import { createContext } from 'react'; @@ -28,26 +28,26 @@ import { createContext } from 'react'; const ThemeContext = createContext('light'); ``` -[See more examples below.](#usage) +[Daha fazla örnek için aşağıya bakınız.](#usage) -#### Parameters {/*parameters*/} +#### Parametreler {/*parameters*/} -* `defaultValue`: The value that you want the context to have when there is no matching context provider in the tree above the component that reads context. If you don't have any meaningful default value, specify `null`. The default value is meant as a "last resort" fallback. It is static and never changes over time. +* `defaultValue`: Context'i okuyan bileşenlerin üzerinde eşleşen bir context sağlayıcısı olmadığında contextin sahip olmasını istediğiniz değer. Anlamlı bir varsayılan değeriniz yoksa, `null` belirtin. Varsayılan değer, "son çare" olarak başvurulacak bir alternatif olarak düşünülür. Statik ve zamanla asla değişmez. -#### Returns {/*returns*/} +#### Geri Dönüş Değeri {/*returns*/} -`createContext` returns a context object. +`createContext` bir context nesnesi döndürür. -**The context object itself does not hold any information.** It represents _which_ context other components read or provide. Typically, you will use [`SomeContext.Provider`](#provider) in components above to specify the context value, and call [`useContext(SomeContext)`](/reference/react/useContext) in components below to read it. The context object has a few properties: +**Context nesnesi kendisi herhangi bir bilgi içermez.** Diğer bileşenlerin _hangi_ contexti okuyacağını veya sağlayacağını temsil eder. Genellikle, context değerini belirtmek için bileşenin üstünde [SomeContext.Provider](https://react.dev/reference/react/createContext#provider) kullanır ve bileşenin altında okumak için [useContext(SomeContext)](https://react.dev/reference/react/useContext) çağırırsınız. Context nesnesinin birkaç özelliği vardır: -* `SomeContext.Provider` lets you provide the context value to components. -* `SomeContext.Consumer` is an alternative and rarely used way to read the context value. +* `SomeContext.Provider` bilenşenlerin context değerini sağlamanıza olanak tanır. +* `SomeContext.Consumer` context değerini okumak için nadiren kullanılan alternatif bir yöntemdir. --- ### `SomeContext.Provider` {/*provider*/} -Wrap your components into a context provider to specify the value of this context for all components inside: +Bileşenlerinizin bir context sağlayıcısı ile sarmalayarak içindeki tüm bileşenler için bu contextin değerini belirtin: ```js function App() { @@ -63,17 +63,18 @@ function App() { #### Props {/*provider-props*/} -* `value`: The value that you want to pass to all the components reading this context inside this provider, no matter how deep. The context value can be of any type. A component calling [`useContext(SomeContext)`](/reference/react/useContext) inside of the provider receives the `value` of the innermost corresponding context provider above it. +* `value`: Ne kadar derin olursa olsun, bu sağlayıcının içindeki contexti okuyan tüm bileşenlere aktarmak istediğiniz değer. Context değeri herhangi bir türde olabilir. Sağlayıcı içinde [`useContext(SomeContext)`](/reference/react/useContext) kullanan bir bileşen, +üzerindeki en içte bulunan ilgili context sağlayıcısının `value` değerini alır. --- ### `SomeContext.Consumer` {/*consumer*/} -Before `useContext` existed, there was an older way to read context: +`useContext` var olmadan önce, contexti okumak için daha eski bir yol vardı: ```js function Button() { - // 🟡 Legacy way (not recommended) + // 🟡 Eski yöntem (önerilmez) return ( {theme => ( @@ -84,11 +85,11 @@ function Button() { } ``` -Although this older way still works, but **newly written code should read context with [`useContext()`](/reference/react/useContext) instead:** +Bu eski yöntem hala çalışıyor olsa da, **yeni yazılan kodun contextini [`useContext()`](/reference/react/useContext) ile okunması daha uygundur:** ```js function Button() { - // ✅ Recommended way + // ✅ Önerilen yöntem const theme = useContext(ThemeContext); return