{"id":37705,"date":"2026-01-13T01:40:49","date_gmt":"2026-01-12T22:40:49","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=37705"},"modified":"2026-01-13T01:40:49","modified_gmt":"2026-01-12T22:40:49","slug":"react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/","title":{"rendered":"React Context API&#8217;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7"},"content":{"rendered":"<p><body><\/p>\n<h2>React Context API&#8217;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7<\/h2>\n<h2>Giri\u015f<\/h2>\n<p>React, modern web uygulamalar\u0131 geli\u015ftirmek i\u00e7in pop\u00fcler bir JavaScript k\u00fct\u00fcphanesidir. Bile\u015fen tabanl\u0131 mimarisi sayesinde karma\u015f\u0131k kullan\u0131c\u0131 aray\u00fczlerini y\u00f6netmeyi kolayla\u015ft\u0131r\u0131r. Ancak, bir React uygulamas\u0131n\u0131n b\u00fcy\u00fcmesiyle birlikte, bile\u015fenler aras\u0131nda veri payla\u015f\u0131m\u0131 \u00f6nemli bir zorluk haline gelebilir. \u00d6zellikle, uygulaman\u0131n derinliklerinde yer alan bir bile\u015fenin, a\u011fac\u0131n tepesindeki bir bile\u015fenden gelen verilere ihtiya\u00e7 duymas\u0131 durumunda ortaya \u00e7\u0131kan &#8220;prop drilling&#8221; problemi, geli\u015ftiricilerin kar\u015f\u0131la\u015ft\u0131\u011f\u0131 yayg\u0131n bir sorundur. React Context API, bu sorunu \u00e7\u00f6zmek ve bile\u015fenler aras\u0131nda veri payla\u015f\u0131m\u0131n\u0131 daha zarif ve verimli bir hale getirmek amac\u0131yla tasarlanm\u0131\u015f g\u00fc\u00e7l\u00fc bir \u00f6zelliktir.<\/p>\n<p>Bu makalede, React Context API&#8217;\u0131n ne oldu\u011funu, neden ortaya \u00e7\u0131kt\u0131\u011f\u0131n\u0131, temel bile\u015fenlerini, nas\u0131l kullan\u0131ld\u0131\u011f\u0131n\u0131, geli\u015fmi\u015f kullan\u0131m senaryolar\u0131n\u0131, performans ipu\u00e7lar\u0131n\u0131 ve di\u011fer durum y\u00f6netim \u00e7\u00f6z\u00fcmleriyle kar\u015f\u0131la\u015ft\u0131rmas\u0131n\u0131 detayl\u0131 bir \u015fekilde inceleyece\u011fiz. Amac\u0131m\u0131z, Context API&#8217;\u0131n derinlemesine anla\u015f\u0131lmas\u0131n\u0131 sa\u011flamak ve onu React uygulamalar\u0131n\u0131zda etkili bir \u015fekilde kullanabilmeniz i\u00e7in size kapsaml\u0131 bir rehber sunmakt\u0131r.<\/p>\n<h3>Prop Drilling Problemi<\/h3>\n<p>React&#8217;te veri ak\u0131\u015f\u0131 genellikle tek y\u00f6nl\u00fcd\u00fcr: \u00fcst bile\u015fenlerden alt bile\u015fenlere prop&#8217;lar arac\u0131l\u0131\u011f\u0131yla. Bu, uygulaman\u0131n durumunu tahmin edilebilir k\u0131lar ve hata ay\u0131klamay\u0131 kolayla\u015ft\u0131r\u0131r. Ancak, bir veri par\u00e7as\u0131n\u0131n bile\u015fen a\u011fac\u0131nda birka\u00e7 katman derine iletilmesi gerekti\u011finde, her ara bile\u015fenin bu prop&#8217;u yaln\u0131zca iletmek i\u00e7in almas\u0131 ve alt bile\u015fenine aktarmas\u0131 gerekir. Bu duruma &#8220;prop drilling&#8221; (prop delme) denir.<\/p>\n<p>\u00d6rne\u011fin, <code>App<\/code> bile\u015feninde tan\u0131mlanm\u0131\u015f bir kullan\u0131c\u0131 nesnesini, <code>App<\/code> -> <code>Dashboard<\/code> -> <code>Sidebar<\/code> -> <code>UserAvatar<\/code> \u015feklinde d\u00f6rt katman derindeki <code>UserAvatar<\/code> bile\u015fenine iletmek istedi\u011finizi d\u00fc\u015f\u00fcn\u00fcn. Bu durumda, <code>Dashboard<\/code> ve <code>Sidebar<\/code> bile\u015fenlerinin, kendi i\u00e7lerinde bu kullan\u0131c\u0131 verisini kullanmasalar bile, onu sadece <code>UserAvatar<\/code>&#8216;a aktarmak i\u00e7in prop olarak almalar\u0131 gerekir.<\/p>\n<pre><code class=\"language-jsx\">\/\/ App.js\nfunction App() {\n  const user = { name: 'Alice', avatarUrl: '...' };\n  return <Dashboard user={user} \/>;\n}\n\n\/\/ Dashboard.js\nfunction Dashboard({ user }) {\n  return (\n    <div>\n      \n      <Sidebar user={user} \/> {\/<em> user prop'unu sadece iletmek i\u00e7in al\u0131yor <\/em>\/}\n    <\/div>\n  );\n}\n\n\/\/ Sidebar.js\nfunction Sidebar({ user }) {\n  return (\n    <aside>\n      <h2>Sidebar<\/h2>\n      <UserAvatar user={user} \/> {\/<em> user prop'unu sadece iletmek i\u00e7in al\u0131yor <\/em>\/}\n    <\/aside>\n  );\n}\n\n\/\/ UserAvatar.js\nfunction UserAvatar({ user }) {\n  return (\n    <div>\n      <img src={user.avatarUrl} alt={user.name} \/>\n      <span>{user.name}<\/span>\n    <\/div>\n  );\n}<\/code><\/pre>\n<p>Bu senaryonun dezavantajlar\u0131 \u015funlard\u0131r:<br \/>\n*   <strong>Kod Okunabilirli\u011fi ve S\u00fcrd\u00fcr\u00fclebilirlik:<\/strong> Ara bile\u015fenler, asl\u0131nda kendi i\u015flevsellikleri i\u00e7in ihtiya\u00e7 duymad\u0131klar\u0131 prop&#8217;lar\u0131 al\u0131r. Bu, kodu daha az okunakl\u0131 ve anlamas\u0131 zor hale getirir.<br \/>\n*   <strong>Yeniden D\u00fczenleme Zorlu\u011fu:<\/strong> E\u011fer \u00fcst bile\u015fendeki veri yap\u0131s\u0131 de\u011fi\u015firse veya veri kayna\u011f\u0131 de\u011fi\u015firse, bu veriyi ileten t\u00fcm ara bile\u015fenlerin g\u00fcncellenmesi gerekir. Bu da yeniden d\u00fczenlemeyi (refactoring) zorla\u015ft\u0131r\u0131r ve hata yapma olas\u0131l\u0131\u011f\u0131n\u0131 art\u0131r\u0131r.<br \/>\n*   <strong>Bile\u015fen Tekrar Kullan\u0131m\u0131:<\/strong> Prop drilling&#8217;e maruz kalan bile\u015fenler, sadece belirli bir prop setini bekledikleri i\u00e7in daha az genel ve daha az tekrar kullan\u0131labilir hale gelirler.<\/p>\n<p>Context API, bu prop drilling sorununu ortadan kald\u0131rarak, verilerin do\u011frudan ihtiya\u00e7 duyan bile\u015fenlere iletilmesini sa\u011flar ve kodun daha temiz, daha s\u00fcrd\u00fcr\u00fclebilir olmas\u0131na yard\u0131mc\u0131 olur.<\/p>\n<h2>Context API ile Tan\u0131\u015fma<\/h2>\n<p>React Context API, React bile\u015fen a\u011fac\u0131nda, prop&#8217;lar\u0131 her seviyede manuel olarak iletmek zorunda kalmadan veri payla\u015f\u0131m\u0131 i\u00e7in bir yol sa\u011flar. Bu, tema bilgisi, kullan\u0131c\u0131 kimlik do\u011frulama durumu veya tercih edilen dil gibi &#8220;k\u00fcresel&#8221; verilere ihtiya\u00e7 duyan bir\u00e7ok bile\u015fen oldu\u011funda \u00f6zellikle kullan\u0131\u015fl\u0131d\u0131r.<\/p>\n<p>Context API&#8217;\u0131n temelinde \u00fc\u00e7 ana kavram yatar: <code>React.createContext()<\/code>, <code>Context.Provider<\/code> ve <code>useContext<\/code> (veya daha eski <code>Context.Consumer<\/code>).<\/p>\n<h3>Temel Kavramlar Detayl\u0131 \u0130ncelenmesi<\/h3>\n<h4>1. <code>React.createContext()<\/code><\/h4>\n<p><code>React.createContext()<\/code> fonksiyonu, bir Context objesi olu\u015fturur. Bu obje, bile\u015fenlerin veriye abone olmas\u0131n\u0131 ve veriyi sa\u011flamas\u0131n\u0131 sa\u011flayan bir k\u00f6pr\u00fc g\u00f6revi g\u00f6r\u00fcr.<\/p>\n<pre><code class=\"language-javascript\">const MyContext = React.createContext(defaultValue);<\/code><\/pre>\n<p>*   <strong><code>defaultValue<\/code>:<\/strong> Bu parametre iste\u011fe ba\u011fl\u0131d\u0131r ve bir Provider taraf\u0131ndan sar\u0131lmam\u0131\u015f bir bile\u015fen (Consumer) taraf\u0131ndan Context de\u011feri istendi\u011finde kullan\u0131lacak de\u011feri belirtir. Bu, genellikle bir yedek de\u011fer veya test ama\u00e7l\u0131 bir de\u011ferdir. E\u011fer bir Consumer, kendisini saran bir Provider olmadan Context&#8217;i kullanmaya \u00e7al\u0131\u015f\u0131rsa, bu <code>defaultValue<\/code>&#8216;yu al\u0131r.<\/p>\n<p><code>createContext()<\/code> fonksiyonu, i\u00e7inde <code>Provider<\/code> ve <code>Consumer<\/code> ad\u0131nda iki React bile\u015feni bar\u0131nd\u0131ran bir obje d\u00f6nd\u00fcr\u00fcr.<\/p>\n<h4>2. <code>Context.Provider<\/code><\/h4>\n<p><code>Context.Provider<\/code>, Context&#8217;e de\u011fer sa\u011flamak i\u00e7in kullan\u0131lan bir React bile\u015fenidir. Bile\u015fen a\u011fac\u0131nda, Context de\u011ferini almas\u0131 gereken t\u00fcm alt bile\u015fenleri sarmalamak i\u00e7in kullan\u0131l\u0131r.<\/p>\n<pre><code class=\"language-jsx\"><MyContext.Provider value={\/<em> herhangi bir JavaScript de\u011feri <\/em>\/}>\n  {\/<em> Bu Context'e abone olacak alt bile\u015fenler <\/em>\/}\n<\/MyContext.Provider><\/code><\/pre>\n<p>*   <strong><code>value<\/code> prop&#8217;u:<\/strong> Bu, Context \u00fczerinden alt bile\u015fenlere iletilecek olan veridir. Bu prop de\u011fi\u015fti\u011finde, bu Provider&#8217;a abone olan t\u00fcm alt bile\u015fenler yeniden render edilir. <code>value<\/code> prop&#8217;una string, number, boolean, obje, dizi, hatta fonksiyon gibi herhangi bir JavaScript de\u011feri ge\u00e7irilebilir.<\/p>\n<p>Bir Provider&#8217;\u0131n de\u011feri de\u011fi\u015fti\u011finde, o Provider&#8217;\u0131n alt\u0131ndaki t\u00fcm Consumer&#8217;lar (ve <code>useContext<\/code> kullanan bile\u015fenler) yeniden render olur. Bu, Context API&#8217;\u0131n \u00e7al\u0131\u015fma prensibinin temelidir.<\/p>\n<h4>3. <code>useContext<\/code> Hook&#8217;u (Modern Yakla\u015f\u0131m)<\/h4>\n<p><code>useContext<\/code> hook&#8217;u, React 16.8 ile tan\u0131t\u0131lan ve functional bile\u015fenlerde Context de\u011ferini t\u00fcketmenin modern ve \u00f6nerilen yoludur.<\/p>\n<pre><code class=\"language-jsx\">import React, { useContext } from 'react';\n\nfunction MyComponent() {\n  const value = useContext(MyContext);\n  \/\/ Context de\u011ferini kullanarak render et\n  return <div>{value}<\/div>;\n}<\/code><\/pre>\n<p>*   <code>useContext<\/code> hook&#8217;u, parametre olarak bir Context objesi (yani <code>React.createContext()<\/code> taraf\u0131ndan d\u00f6nd\u00fcr\u00fclen obje) al\u0131r ve o Context&#8217;in g\u00fcncel de\u011ferini d\u00f6nd\u00fcr\u00fcr.<br \/>\n*   <code>useContext<\/code>&#8216;i \u00e7a\u011f\u0131ran bile\u015fen, en yak\u0131n \u00fcst\u00fcndeki <code>MyContext.Provider<\/code>&#8216;\u0131n <code>value<\/code> prop&#8217;una abone olur. E\u011fer bu <code>value<\/code> de\u011fi\u015firse, <code>useContext<\/code>&#8216;i \u00e7a\u011f\u0131ran bile\u015fen otomatik olarak yeniden render olur.<br \/>\n*   E\u011fer bir <code>MyContext.Provider<\/code> yukar\u0131da bulunamazsa, <code>useContext<\/code> hook&#8217;u, <code>React.createContext(defaultValue)<\/code>&#8216;ya ge\u00e7irilen <code>defaultValue<\/code>&#8216;yu d\u00f6nd\u00fcr\u00fcr.<\/p>\n<p><code>useContext<\/code> hook&#8217;u, <code>Context.Consumer<\/code>&#8216;a g\u00f6re \u00e7ok daha temiz ve okunabilir bir sentaksa sahiptir ve functional bile\u015fenlerde Context kullanman\u0131n tercih edilen yoludur.<\/p>\n<h4>4. <code>Context.Consumer<\/code> (Eski Yakla\u015f\u0131m)<\/h4>\n<p><code>Context.Consumer<\/code> bile\u015feni, class bile\u015fenlerinde veya <code>useContext<\/code> hook&#8217;unun olmad\u0131\u011f\u0131 React&#8217;in daha eski versiyonlar\u0131nda Context de\u011ferini t\u00fcketmek i\u00e7in kullan\u0131l\u0131rd\u0131. Genellikle &#8220;render prop&#8221; deseniyle \u00e7al\u0131\u015f\u0131r.<\/p>\n<pre><code class=\"language-jsx\"><MyContext.Consumer>\n  {value => (\n    {\/<em> Context de\u011ferini kullanarak render et <\/em>\/}\n    <div>{value}<\/div>\n  )}\n<\/MyContext.Consumer><\/code><\/pre>\n<p>*   <code>Context.Consumer<\/code> bir fonksiyonu \u00e7ocuk olarak bekler. Bu fonksiyon, Context&#8217;in g\u00fcncel de\u011ferini arg\u00fcman olarak al\u0131r ve bu de\u011fere ba\u011fl\u0131 olarak React elementlerini d\u00f6nd\u00fcr\u00fcr.<br \/>\n*   Birden fazla Context t\u00fcketilmesi gerekti\u011finde i\u00e7 i\u00e7e <code>Consumer<\/code>&#8216;lar kullanmak zorunda kalmak, kodun okunabilirli\u011fini \u00f6nemli \u00f6l\u00e7\u00fcde azaltabilir. Bu nedenle, <code>useContext<\/code> hook&#8217;u varken <code>Context.Consumer<\/code> kullanmaktan ka\u00e7\u0131n\u0131lmas\u0131 \u00f6nerilir.<\/p>\n<h2>Context API&#8217;\u0131 Uygulama: Ad\u0131m Ad\u0131m Rehber<\/h2>\n<p>\u015eimdi, Context API&#8217;\u0131 ger\u00e7ek bir senaryoda nas\u0131l kullanaca\u011f\u0131m\u0131z\u0131 ad\u0131m ad\u0131m inceleyelim. Bir tema de\u011fi\u015ftirme (a\u00e7\u0131k\/koyu mod) uygulamas\u0131n\u0131 ele alal\u0131m.<\/p>\n<p><strong>Senaryo:<\/strong> Uygulamam\u0131zda bir tema (light\/dark) bilgisini global olarak tutmak ve farkl\u0131 bile\u015fenlerin bu temaya eri\u015fmesini ve hatta temay\u0131 de\u011fi\u015ftirmesini sa\u011flamak istiyoruz.<\/p>\n<p><strong>Ad\u0131m 1: Context Olu\u015fturma<\/strong><br \/>\n\u0130lk olarak, tema bilgisini ta\u015f\u0131yacak bir Context objesi olu\u015fturmam\u0131z gerekiyor. Genellikle, Context&#8217;i ayr\u0131 bir dosyada tan\u0131mlamak iyi bir uygulamad\u0131r.<\/p>\n<pre><code class=\"language-jsx\">\/\/ contexts\/ThemeContext.js\nimport React, { createContext, useState, useMemo, useCallback } from 'react';\n\n\/\/ Varsay\u0131lan tema 'light' olarak belirlendi\nexport const ThemeContext = createContext('light');\n\nexport function ThemeProvider({ children }) {\n  const [theme, setTheme] = useState('light');\n\n  \/\/ Tema de\u011fi\u015ftirme fonksiyonu\n  const toggleTheme = useCallback(() => {\n    setTheme(prevTheme => (prevTheme === 'light' ? 'dark' : 'light'));\n  }, []);\n\n  \/\/ Context'e sa\u011flanacak de\u011feri useMemo ile memoize ediyoruz\n  \/\/ Bu, Provider'\u0131n value prop'u de\u011fi\u015fmedi\u011fi s\u00fcrece alt bile\u015fenlerin gereksiz yere render olmas\u0131n\u0131 engeller.\n  const contextValue = useMemo(() => ({ theme, toggleTheme }), [theme, toggleTheme]);\n\n  return (\n    <ThemeContext.Provider value={contextValue}>\n      {children}\n    <\/ThemeContext.Provider>\n  );\n}<\/code><\/pre>\n<p>Burada <code>ThemeContext<\/code>&#8216;i olu\u015fturduk ve ayr\u0131ca bu Context&#8217;i y\u00f6netecek bir <code>ThemeProvider<\/code> bile\u015feni tan\u0131mlad\u0131k. <code>ThemeProvider<\/code> i\u00e7inde <code>useState<\/code> kullanarak tema durumunu y\u00f6nettik ve <code>toggleTheme<\/code> fonksiyonunu <code>useCallback<\/code> ile memoize ettik. <code>contextValue<\/code> objesini de <code>useMemo<\/code> ile memoize ederek, <code>theme<\/code> veya <code>toggleTheme<\/code> de\u011fi\u015fmedi\u011fi s\u00fcrece <code>Provider<\/code>&#8216;\u0131n <code>value<\/code> prop&#8217;unun ayn\u0131 kalmas\u0131n\u0131 sa\u011flad\u0131k. Bu, performans optimizasyonu i\u00e7in \u00f6nemlidir.<\/p>\n<p><strong>Ad\u0131m 2: Provider Kullanarak De\u011fer Sa\u011flama<\/strong><br \/>\n\u015eimdi, uygulamam\u0131z\u0131n hangi k\u0131sm\u0131n\u0131n tema Context&#8217;ine eri\u015febilece\u011fini belirlemek i\u00e7in <code>ThemeProvider<\/code>&#8216;\u0131 kullanmam\u0131z gerekiyor. Genellikle, bu Provider&#8217;\u0131 uygulaman\u0131n en \u00fcst seviyesine (\u00f6rne\u011fin <code>App.js<\/code> i\u00e7inde) yerle\u015ftiririz.<\/p>\n<pre><code class=\"language-jsx\">\/\/ App.js\nimport React from 'react';\nimport { ThemeProvider } from '.\/contexts\/ThemeContext';\nimport Toolbar from '.\/components\/Toolbar';\nimport Content from '.\/components\/Content';\nimport '.\/App.css'; \/\/ Tema ile ilgili stil dosyas\u0131\n\nfunction App() {\n  return (\n    <ThemeProvider>\n      {\/<em> Tema Context'ine eri\u015febilecek t\u00fcm bile\u015fenler buraya gelecek <\/em>\/}\n      <div className=\"App\">\n        <Toolbar \/>\n        <Content \/>\n      <\/div>\n    <\/ThemeProvider>\n  );\n}\n\nexport default App;<\/code><\/pre>\n<p>Art\u0131k <code>Toolbar<\/code> ve <code>Content<\/code> (ve onlar\u0131n alt bile\u015fenleri) tema Context&#8217;ine eri\u015febilecekler.<\/p>\n<p><strong>Ad\u0131m 3: <code>useContext<\/code> ile De\u011fer T\u00fcketme<\/strong><br \/>\nSon olarak, tema de\u011ferini ve temay\u0131 de\u011fi\u015ftirme fonksiyonunu ihtiyac\u0131m\u0131z olan bile\u015fenlerde <code>useContext<\/code> hook&#8217;u ile t\u00fcketebiliriz.<\/p>\n<pre><code class=\"language-jsx\">\/\/ components\/Toolbar.js\nimport React, { useContext } from 'react';\nimport { ThemeContext } from '..\/contexts\/ThemeContext';\n\nfunction Toolbar() {\n  const { theme, toggleTheme } = useContext(ThemeContext);\n\n  return (\n    <header style={{ background: theme === 'dark' ? '#333' : '#f0f0f0', color: theme === 'dark' ? '#fff' : '#333' }}>\n      \n      <button onClick={toggleTheme}>\n        Temay\u0131 De\u011fi\u015ftir ({theme === 'light' ? 'Karanl\u0131k' : 'Ayd\u0131nl\u0131k'})\n      <\/button>\n    <\/header>\n  );\n}\n\nexport default Toolbar;<\/code><\/pre>\n<pre><code class=\"language-jsx\">\/\/ components\/Content.js\nimport React, { useContext } from 'react';\nimport { ThemeContext } from '..\/contexts\/ThemeContext';\n\nfunction Content() {\n  const { theme } = useContext(ThemeContext);\n\n  return (\n    <main style={{ background: theme === 'dark' ? '#555' : '#fff', color: theme === 'dark' ? '#fff' : '#333' }}>\n      <p>Bu, uygulaman\u0131n ana i\u00e7eri\u011fidir.<\/p>\n      <p>Mevcut tema: {theme}<\/p>\n    <\/main>\n  );\n}\n\nexport default Content;<\/code><\/pre>\n<p>Bu \u00f6rnekte, <code>Toolbar<\/code> bile\u015feni hem mevcut temay\u0131 okuyor hem de <code>toggleTheme<\/code> fonksiyonunu \u00e7a\u011f\u0131rarak temay\u0131 de\u011fi\u015ftirebiliyor. <code>Content<\/code> bile\u015feni ise sadece mevcut temay\u0131 okuyup, i\u00e7eri\u011fini buna g\u00f6re bi\u00e7imlendiriyor. Bu \u015fekilde, prop drilling yapmadan uygulaman\u0131n farkl\u0131 yerlerindeki bile\u015fenler global tema durumuna eri\u015febiliyor ve onu manip\u00fcle edebiliyor.<\/p>\n<h2>Geli\u015fmi\u015f Kullan\u0131m ve En \u0130yi Uygulamalar<\/h2>\n<h3>Context&#8217;ten Durum G\u00fcncelleme<\/h3>\n<p>Yukar\u0131daki tema \u00f6rne\u011finde g\u00f6sterildi\u011fi gibi, Context sadece veri sa\u011flamakla kalmaz, ayn\u0131 zamanda bu veriyi g\u00fcncelleyecek fonksiyonlar\u0131 da sa\u011flayabilir. Bu, alt bile\u015fenlerin Context&#8217;teki durumu de\u011fi\u015ftirmesine olanak tan\u0131r. <code>useState<\/code> veya <code>useReducer<\/code> hook&#8217;lar\u0131 ile birlikte kullan\u0131ld\u0131\u011f\u0131nda, Context API olduk\u00e7a g\u00fc\u00e7l\u00fc bir durum y\u00f6netim arac\u0131 haline gelir.<\/p>\n<pre><code class=\"language-jsx\">\/\/ UserContext.js\nimport React, { createContext, useState, useMemo, useCallback } from 'react';\n\nexport const UserContext = createContext(null); \/\/ Varsay\u0131lan de\u011fer null\n\nexport function UserProvider({ children }) {\n  const [user, setUser] = useState(null); \/\/ Ba\u015flang\u0131\u00e7ta kullan\u0131c\u0131 yok\n\n  const login = useCallback((username, password) => {\n    \/\/ API \u00e7a\u011fr\u0131s\u0131 veya do\u011frulama mant\u0131\u011f\u0131 burada olur\n    if (username === 'test' && password === '123') {\n      setUser({ id: 1, name: 'Test User' });\n      return true;\n    }\n    return false;\n  }, []);\n\n  const logout = useCallback(() => {\n    setUser(null);\n  }, []);\n\n  const contextValue = useMemo(() => ({ user, login, logout }), [user, login, logout]);\n\n  return (\n    <UserContext.Provider value={contextValue}>\n      {children}\n    <\/UserContext.Provider>\n  );\n}<\/code><\/pre>\n<p>Bu <code>UserProvider<\/code>, <code>user<\/code> objesi ile birlikte <code>login<\/code> ve <code>logout<\/code> fonksiyonlar\u0131n\u0131 da sa\u011flar. Art\u0131k herhangi bir alt bile\u015fen <code>useContext(UserContext)<\/code>&#8216;i kullanarak bu fonksiyonlara eri\u015febilir ve kullan\u0131c\u0131 durumunu de\u011fi\u015ftirebilir.<\/p>\n<h3>Birden Fazla Context Kullan\u0131m\u0131<\/h3>\n<p>Bir uygulamada birden fazla global veri par\u00e7as\u0131 olabilir ve her biri i\u00e7in ayr\u0131 bir Context olu\u015fturmak isteyebilirsiniz (\u00f6rne\u011fin, <code>ThemeContext<\/code>, <code>UserContext<\/code>, <code>LanguageContext<\/code>). Bu durumda, <code>Provider<\/code>&#8216;lar\u0131 i\u00e7 i\u00e7e yerle\u015ftirebilirsiniz:<\/p>\n<pre><code class=\"language-jsx\">\/\/ App.js\nimport React from 'react';\nimport { ThemeProvider } from '.\/contexts\/ThemeContext';\nimport { UserProvider } from '.\/contexts\/UserContext';\nimport { LanguageProvider } from '.\/contexts\/LanguageContext';\nimport MyComponent from '.\/components\/MyComponent';\n\nfunction App() {\n  return (\n    <ThemeProvider>\n      <UserProvider>\n        <LanguageProvider>\n          <MyComponent \/>\n        <\/LanguageProvider>\n      <\/UserProvider>\n    <\/ThemeProvider>\n  );\n}<\/code><\/pre>\n<p>Bu yakla\u015f\u0131m, uygulaman\u0131n \u00e7ok fazla Context&#8217;i oldu\u011funda &#8220;Provider Hell&#8221; (Provider Cehennemi) olarak adland\u0131r\u0131lan bir duruma yol a\u00e7abilir. Bu durumu hafifletmek i\u00e7in, t\u00fcm Provider&#8217;lar\u0131 tek bir bile\u015fende birle\u015ftiren bir &#8220;Mega Provider&#8221; olu\u015fturabilirsiniz:<\/p>\n<pre><code class=\"language-jsx\">\/\/ contexts\/AppProviders.js\nimport React from 'react';\nimport { ThemeProvider } from '.\/ThemeContext';\nimport { UserProvider } from '.\/UserContext';\nimport { LanguageProvider } from '.\/LanguageContext';\n\nfunction AppProviders({ children }) {\n  return (\n    <ThemeProvider>\n      <UserProvider>\n        <LanguageProvider>\n          {children}\n        <\/LanguageProvider>\n      <\/UserProvider>\n    <\/ThemeProvider>\n  );\n}\n\nexport default AppProviders;\n\n\/\/ App.js\nimport React from 'react';\nimport AppProviders from '.\/contexts\/AppProviders';\nimport MyComponent from '.\/components\/MyComponent';\n\nfunction App() {\n  return (\n    <AppProviders>\n      <MyComponent \/>\n    <\/AppProviders>\n  );\n}<\/code><\/pre>\n<p>Bu, <code>App.js<\/code> dosyas\u0131n\u0131 daha temiz tutar.<\/p>\n<h3>Performans Konular\u0131 ve Optimizasyon<\/h3>\n<p>Context API&#8217;\u0131n \u00f6nemli bir \u00f6zelli\u011fi ve potansiyel dezavantaj\u0131 \u015fudur: Bir <code>Context.Provider<\/code>&#8216;\u0131n <code>value<\/code> prop&#8217;u de\u011fi\u015fti\u011finde, o Provider&#8217;a abone olan <em>t\u00fcm<\/em> alt bile\u015fenler (yani <code>useContext<\/code> kullanan veya <code>Context.Consumer<\/code> i\u00e7indeki render prop fonksiyonu) yeniden render edilir. Bu, <code>value<\/code> prop&#8217;u her render&#8217;da yeni bir obje olu\u015fturuyorsa, gereksiz yeniden render&#8217;lara yol a\u00e7abilir.<\/p>\n<pre><code class=\"language-jsx\">function MyProvider({ children }) {\n  const [count, setCount] = useState(0);\n\n  \/\/ Her render'da yeni bir obje olu\u015fturulur\n  \/\/ Bu, alt bile\u015fenlerin gereksiz yere render olmas\u0131na neden olabilir\n  const contextValue = { count, setCount }; \n\n  return (\n    <MyContext.Provider value={contextValue}>\n      {children}\n    <\/MyContext.Provider>\n  );\n}<\/code><\/pre>\n<p>Bu durumda, <code>MyProvider<\/code> her render oldu\u011funda (\u00f6rne\u011fin, \u00fcst bile\u015feninden bir prop de\u011fi\u015fti\u011fi i\u00e7in), <code>contextValue<\/code> objesi yeniden olu\u015fturulur. React, <code>value<\/code> prop&#8217;unu bir \u00f6nceki render&#8217;daki <code>value<\/code> prop&#8217;uyla s\u0131\u011f kar\u015f\u0131la\u015ft\u0131rma (shallow comparison) yapar. Yeni bir obje her zaman eski bir objeden farkl\u0131 olaca\u011f\u0131 i\u00e7in, <code>value<\/code> prop&#8217;unun de\u011fi\u015fti\u011fini varsayar ve t\u00fcm t\u00fcketicileri yeniden render eder.<\/p>\n<p><strong>Optimizasyon Y\u00f6ntemleri:<\/strong><\/p>\n<p>1.  <strong><code>useMemo<\/code> ile <code>value<\/code>&#8216;yu Memoize Etme:<\/strong><br \/>\n    <code>value<\/code> prop&#8217;una ge\u00e7irilen objeyi <code>useMemo<\/code> kullanarak memoize etmek, yaln\u0131zca ba\u011f\u0131ml\u0131l\u0131klar\u0131 de\u011fi\u015fti\u011finde yeni bir obje olu\u015fturulmas\u0131n\u0131 sa\u011flar.<\/p>\n<pre><code class=\"language-jsx\">function MyProvider({ children }) {\n      const [count, setCount] = useState(0);\n\n      \/\/ contextValue objesi sadece count de\u011fi\u015fti\u011finde yeniden olu\u015fturulur\n      const contextValue = useMemo(() => ({ count, setCount }), [count]); \n\n      return (\n        <MyContext.Provider value={contextValue}>\n          {children}\n        <\/MyContext.Provider>\n      );\n    }<\/code><\/pre>\n<p>    Bu, <code>MyProvider<\/code>&#8216;\u0131n kendisi yeniden render olsa bile, <code>count<\/code> de\u011fi\u015fmedi\u011fi s\u00fcrece <code>contextValue<\/code> objesinin referans\u0131n\u0131n ayn\u0131 kalmas\u0131n\u0131 sa\u011flar. B\u00f6ylece, <code>useContext<\/code> kullanan alt bile\u015fenler gereksiz yere yeniden render olmaz. Fonksiyonlar\u0131 da <code>useCallback<\/code> ile memoize etmek \u00f6nemlidir, \u00e7\u00fcnk\u00fc fonksiyon referanslar\u0131 da her render&#8217;da de\u011fi\u015febilir ve bu da <code>useMemo<\/code>&#8216;nun ba\u011f\u0131ml\u0131l\u0131k dizisindeki referanslar\u0131 etkiler.<\/p>\n<p>2.  <strong>Context&#8217;leri B\u00f6lme:<\/strong><br \/>\n    B\u00fcy\u00fck bir Context yerine, farkl\u0131 veri par\u00e7alar\u0131 i\u00e7in daha k\u00fc\u00e7\u00fck, daha odakl\u0131 Context&#8217;ler olu\u015fturmak, gereksiz yeniden render&#8217;lar\u0131 azaltmaya yard\u0131mc\u0131 olabilir. \u00d6rne\u011fin, bir <code>UserContext<\/code> i\u00e7inde <code>userName<\/code>, <code>userEmail<\/code>, <code>preferences<\/code> gibi bir\u00e7ok veri varsa ve sadece <code>userName<\/code> de\u011fi\u015fti\u011finde t\u00fcm bu veriye abone olan bile\u015fenlerin yeniden render olmas\u0131n\u0131 istemiyorsan\u0131z, <code>UserPreferencesContext<\/code> gibi ayr\u0131 bir Context olu\u015fturabilirsiniz.<\/p>\n<pre><code class=\"language-jsx\">\/\/ Bad: T\u00fcm kullan\u0131c\u0131 verisi tek bir Context'te\n    const UserContext = createContext({ name: '', email: '', preferences: {} });\n\n    \/\/ Good: Verileri daha k\u00fc\u00e7\u00fck Context'lere b\u00f6lme\n    const UserInfoContext = createContext({ name: '', email: '' });\n    const UserPreferencesContext = createContext({});<\/code><\/pre>\n<p>    Bu sayede, <code>UserPreferencesContext<\/code>&#8216;e abone olan bir bile\u015fen sadece tercihler de\u011fi\u015fti\u011finde, <code>UserInfoContext<\/code>&#8216;e abone olan bir bile\u015fen ise sadece kullan\u0131c\u0131 bilgileri de\u011fi\u015fti\u011finde yeniden render olur.<\/p>\n<h3>Context API vs. Redux\/Zustand\/Jotai (Durum Y\u00f6netim K\u00fct\u00fcphaneleri)<\/h3>\n<p>Context API, React&#8217;in yerle\u015fik bir \u00f6zelli\u011fi olsa da, Redux, Zustand, Jotai gibi \u00fc\u00e7\u00fcnc\u00fc taraf durum y\u00f6netim k\u00fct\u00fcphaneleriyle s\u0131kl\u0131kla kar\u015f\u0131la\u015ft\u0131r\u0131l\u0131r. Her birinin kendi kullan\u0131m senaryolar\u0131 ve avantajlar\u0131 vard\u0131r:<\/p>\n<p>*   <strong>Context API:<\/strong><br \/>\n    *   <strong>Avantajlar:<\/strong> Harici bir k\u00fct\u00fcphaneye ba\u011f\u0131ml\u0131l\u0131k yok, React&#8217;in bir par\u00e7as\u0131, \u00f6\u011frenmesi nispeten kolay, k\u00fc\u00e7\u00fck ve orta \u00f6l\u00e7ekli uygulamalar veya belirli alt a\u011fa\u00e7lar i\u00e7in global durum y\u00f6netimi i\u00e7in ideal. <code>useReducer<\/code> ile birle\u015ftirildi\u011finde, Redux benzeri bir yap\u0131 olu\u015fturulabilir.<br \/>\n    *   <strong>Dezavantajlar:<\/strong> Performans optimizasyonu manuel \u00e7aba gerektirebilir (\u00f6zellikle b\u00fcy\u00fck ve s\u0131k de\u011fi\u015fen durumlar i\u00e7in), Redux gibi geli\u015fmi\u015f geli\u015ftirici ara\u00e7lar\u0131 ve middleware deste\u011fi yoktur, karma\u015f\u0131k durum mant\u0131\u011f\u0131 i\u00e7in boilerplate kodu artabilir.<\/p>\n<p>*   <strong>Redux (veya Redux Toolkit):<\/strong><br \/>\n    *   <strong>Avantajlar:<\/strong> B\u00fcy\u00fck ve karma\u015f\u0131k uygulamalar i\u00e7in kan\u0131tlanm\u0131\u015f bir \u00e7\u00f6z\u00fcm, g\u00fc\u00e7l\u00fc geli\u015ftirici ara\u00e7lar\u0131 (Redux DevTools), middleware deste\u011fi (async i\u015flemler, logger vb.), durum y\u00f6netiminde kat\u0131 bir yap\u0131 sa\u011flar, performans optimizasyonlar\u0131 genellikle k\u00fct\u00fcphane taraf\u0131ndan y\u00f6netilir.<br \/>\n    *   <strong>Dezavantajlar:<\/strong> \u00d6\u011frenme e\u011frisi daha dik, daha fazla boilerplate kodu gerektirebilir (Redux Toolkit bu durumu b\u00fcy\u00fck \u00f6l\u00e7\u00fcde iyile\u015ftirir), k\u00fc\u00e7\u00fck uygulamalar i\u00e7in a\u015f\u0131r\u0131ya ka\u00e7abilir.<\/p>\n<p>*   <strong>Zustand, Jotai, Recoil:<\/strong><br \/>\n    *   <strong>Avantajlar:<\/strong> Hafif, basit API&#8217;lar, Redux&#8217;a g\u00f6re daha az boilerplate, modern React paradigmas\u0131na daha uygun (atomik durum y\u00f6netimi gibi), genellikle iyi performans.<br \/>\n    *   <strong>Dezavantajlar:<\/strong> Redux kadar geni\u015f bir ekosistem ve topluluk deste\u011fi hen\u00fcz olmayabilir, \u00e7ok karma\u015f\u0131k veya b\u00fcy\u00fck \u00f6l\u00e7ekli uygulamalar i\u00e7in Redux&#8217;un sa\u011flad\u0131\u011f\u0131 yap\u0131sal faydalardan yoksun kalabilir.<\/p>\n<p><strong>Ne Zaman Hangisi Kullan\u0131lmal\u0131?<\/strong><br \/>\n*   <strong>Context API&#8217;\u0131 kullan\u0131n:<\/strong><br \/>\n    *   Uygulaman\u0131z k\u00fc\u00e7\u00fck veya orta \u00f6l\u00e7ekliyse.<br \/>\n    *   Durumunuz nispeten basit ve nadiren g\u00fcncelleniyorsa (tema, dil, kimlik do\u011frulama).<br \/>\n    *   Harici bir ba\u011f\u0131ml\u0131l\u0131k eklemek istemiyorsan\u0131z.<br \/>\n    *   <code>useReducer<\/code> ile birlikte, Redux benzeri basit bir durum y\u00f6netimi \u00e7\u00f6z\u00fcm\u00fcne ihtiyac\u0131n\u0131z varsa.<br \/>\n*   <strong>Redux veya benzeri bir k\u00fct\u00fcphane kullan\u0131n:<\/strong><br \/>\n    *   Uygulaman\u0131z b\u00fcy\u00fck ve karma\u015f\u0131ksa.<br \/>\n    *   Durumunuz s\u0131k s\u0131k g\u00fcncelleniyor ve \u00e7ok say\u0131da farkl\u0131 bile\u015fen taraf\u0131ndan kullan\u0131l\u0131yorsa.<br \/>\n    *   Geli\u015fmi\u015f geli\u015ftirici ara\u00e7lar\u0131na, middleware&#8217;e ve kapsaml\u0131 bir ekosisteme ihtiyac\u0131n\u0131z varsa.<br \/>\n    *   Durum y\u00f6netiminde kat\u0131 bir yap\u0131 ve \u00f6ng\u00f6r\u00fclebilirlik ar\u0131yorsan\u0131z.<\/p>\n<p>Unutulmamal\u0131d\u0131r ki, Context API bir durum y\u00f6netim k\u00fct\u00fcphanesinin <em>yerini tutmaz<\/em>, ancak belirli durum y\u00f6netimi ihtiya\u00e7lar\u0131 i\u00e7in m\u00fckemmel bir ara\u00e7t\u0131r. Hatta, bir\u00e7ok modern durum y\u00f6netim k\u00fct\u00fcphanesi (Zustand, Jotai gibi) temelinde Context API&#8217;\u0131 kullan\u0131r.<\/p>\n<h3>Context i\u00e7in \u00d6zel Hook&#8217;lar Olu\u015fturma<\/h3>\n<p>Context t\u00fcketimini daha temiz ve yeniden kullan\u0131labilir hale getirmek i\u00e7in \u00f6zel hook&#8217;lar olu\u015fturmak iyi bir uygulamad\u0131r. Bu, hem Context&#8217;i kullanman\u0131n karma\u015f\u0131kl\u0131\u011f\u0131n\u0131 soyutlar hem de hata denetimi eklemenize olanak tan\u0131r.<\/p>\n<pre><code class=\"language-jsx\">\/\/ hooks\/useTheme.js\nimport { useContext } from 'react';\nimport { ThemeContext } from '..\/contexts\/ThemeContext';\n\nexport function useTheme() {\n  const context = useContext(ThemeContext);\n\n  if (context === undefined) {\n    throw new Error('useTheme hook must be used within a ThemeProvider');\n  }\n\n  return context;\n}\n\n\/\/ components\/Toolbar.js (eski hali)\n\/\/ import React, { useContext } from 'react';\n\/\/ import { ThemeContext } from '..\/contexts\/ThemeContext';\n\/\/ function Toolbar() {\n\/\/   const { theme, toggleTheme } = useContext(ThemeContext);\n\/\/   \/\/ ...\n\/\/ }\n\n\/\/ components\/Toolbar.js (yeni hali)\nimport React from 'react';\nimport { useTheme } from '..\/hooks\/useTheme'; \/\/ \u00d6zel hook'u import et\n\nfunction Toolbar() {\n  const { theme, toggleTheme } = useTheme(); \/\/ Daha temiz kullan\u0131m\n  \/\/ ...\n}<\/code><\/pre>\n<p>Bu <code>useTheme<\/code> \u00f6zel hook&#8217;u, <code>ThemeContext<\/code>&#8216;i do\u011frudan t\u00fcketmek yerine bir soyutlama katman\u0131 sa\u011flar. Ayr\u0131ca, e\u011fer <code>useTheme<\/code> hook&#8217;u bir <code>ThemeProvider<\/code> d\u0131\u015f\u0131nda \u00e7a\u011fr\u0131l\u0131rsa, anlaml\u0131 bir hata mesaj\u0131 f\u0131rlatarak geli\u015ftirme s\u0131ras\u0131nda hatalar\u0131 yakalamaya yard\u0131mc\u0131 olur.<\/p>\n<h2>Context API&#8217;\u0131n S\u0131n\u0131rlamalar\u0131<\/h2>\n<p>Context API&#8217;\u0131n g\u00fc\u00e7l\u00fc bir ara\u00e7 olmas\u0131na ra\u011fmen, baz\u0131 s\u0131n\u0131rlamalar\u0131 vard\u0131r:<\/p>\n<p><em>   <strong>Performans:<\/strong> Daha \u00f6nce de belirtildi\u011fi gibi, bir <code>Provider<\/code>&#8216;\u0131n <code>value<\/code> prop&#8217;u de\u011fi\u015fti\u011finde, o <code>Provider<\/code>&#8216;a abone olan <\/em>t\u00fcm* bile\u015fenler yeniden render edilir. Bu, b\u00fcy\u00fck ve s\u0131k g\u00fcncellenen durumlar i\u00e7in performans sorunlar\u0131na yol a\u00e7abilir. <code>useMemo<\/code> ve <code>useCallback<\/code> gibi optimizasyon teknikleri gereklidir ancak her zaman yeterli olmayabilir.<br \/>\n*   <strong>Karma\u015f\u0131kl\u0131k:<\/strong> \u00c7ok say\u0131da farkl\u0131 durumu y\u00f6netmek veya karma\u015f\u0131k durum mant\u0131\u011f\u0131 uygulamak i\u00e7in Context API tek ba\u015f\u0131na yeterli olmayabilir. <code>useReducer<\/code> ile birle\u015ftirilse bile, Redux gibi k\u00fct\u00fcphanelerin sundu\u011fu yap\u0131sal avantajlardan ve geli\u015ftirici deneyiminden yoksun kalabilir.<br \/>\n*   <strong>Geli\u015ftirici Deneyimi:<\/strong> Redux DevTools gibi ara\u00e7lar, durumun nas\u0131l de\u011fi\u015fti\u011fini izlemek ve hata ay\u0131klamak i\u00e7in paha bi\u00e7ilmezdir. Context API&#8217;\u0131n kendisi bu t\u00fcr yerle\u015fik ara\u00e7lar\u0131 sa\u011flamaz.<\/p>\n<h2>Sonu\u00e7<\/h2>\n<p>React Context API, React uygulamalar\u0131nda prop drilling sorununu \u00e7\u00f6zmek ve bile\u015fenler aras\u0131nda veri payla\u015f\u0131m\u0131n\u0131 basitle\u015ftirmek i\u00e7in g\u00fc\u00e7l\u00fc ve esnek bir mekanizma sunar. <code>createContext<\/code>, <code>Provider<\/code> ve <code>useContext<\/code> gibi temel kavramlar\u0131 anlayarak, tema y\u00f6netimi, kullan\u0131c\u0131 kimlik do\u011frulamas\u0131 ve dil tercihleri gibi global durumlar\u0131 etkili bir \u015fekilde y\u00f6netebilirsiniz.<\/p>\n<p>Context API, React&#8217;in yerle\u015fik bir \u00f6zelli\u011fi olmas\u0131 nedeniyle harici ba\u011f\u0131ml\u0131l\u0131klar\u0131 azalt\u0131r ve k\u00fc\u00e7\u00fckten orta \u00f6l\u00e7ekli uygulamalar i\u00e7in m\u00fckemmel bir se\u00e7imdir. Ancak, b\u00fcy\u00fck ve karma\u015f\u0131k uygulamalarda performans sorunlar\u0131n\u0131 \u00f6nlemek i\u00e7in <code>useMemo<\/code> ve <code>useCallback<\/code> gibi optimizasyon tekniklerini kullanmak veya Context&#8217;leri daha k\u00fc\u00e7\u00fck par\u00e7alara b\u00f6lmek \u00f6nemlidir.<\/p>\n<p>Context API, Redux gibi kapsaml\u0131 durum y\u00f6netim k\u00fct\u00fcphanelerinin yerini do\u011frudan almasa da, <code>useReducer<\/code> ile birle\u015ftirildi\u011finde olduk\u00e7a yetenekli bir durum y\u00f6netim \u00e7\u00f6z\u00fcm\u00fc haline gelebilir. Hangi arac\u0131 se\u00e7ece\u011finiz, uygulaman\u0131z\u0131n \u00f6l\u00e7e\u011fine, karma\u015f\u0131kl\u0131\u011f\u0131na ve \u00f6zel ihtiya\u00e7lar\u0131na ba\u011fl\u0131d\u0131r.<\/p>\n<p>Sonu\u00e7 olarak, React geli\u015ftiricisi olarak Context API&#8217;\u0131 derinlemesine anlamak, daha temiz, daha s\u00fcrd\u00fcr\u00fclebilir ve daha performansl\u0131 React uygulamalar\u0131 yazman\u0131za yard\u0131mc\u0131 olacak temel bir beceridir. Do\u011fru kullan\u0131ld\u0131\u011f\u0131nda, React Context API, geli\u015ftirme s\u00fcrecinizi \u00f6nemli \u00f6l\u00e7\u00fcde kolayla\u015ft\u0131rabilir.<br \/>\n<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"React Context API&#8217;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7\nGiri\u015f\nReact, modern web uygulamalar\u0131 geli\u015ftirmek i\u00e7in pop\u00fcler bir JavaScrip","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[128],"tags":[],"class_list":{"0":"post-37705","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-react","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>React Context API&#039;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7 - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React Context API&#039;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7\" \/>\n<meta property=\"og:description\" content=\"React Context API&#039;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7 Giri\u015f React, modern web uygulamalar\u0131 geli\u015ftirmek i\u00e7in pop\u00fcler bir JavaScrip\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-12T22:40:49+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"React Context API&#8217;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7\",\"datePublished\":\"2026-01-12T22:40:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/\"},\"wordCount\":2714,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"React\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/#respond\"]}],\"copyrightYear\":\"2026\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/\",\"name\":\"React Context API'\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7 - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2026-01-12T22:40:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React Context API&#8217;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"React Context API'\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7 - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/","og_locale":"tr_TR","og_type":"article","og_title":"React Context API'\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7","og_description":"React Context API'\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7 Giri\u015f React, modern web uygulamalar\u0131 geli\u015ftirmek i\u00e7in pop\u00fcler bir JavaScrip","og_url":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2026-01-12T22:40:49+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"17 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"React Context API&#8217;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7","datePublished":"2026-01-12T22:40:49+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/"},"wordCount":2714,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["React"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/#respond"]}],"copyrightYear":"2026","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/","url":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/","name":"React Context API'\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7 - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2026-01-12T22:40:49+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/react-context-apii-anlamak-durum-yonetiminde-guclu-bir-arac\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"React Context API&#8217;\u0131 Anlamak: Durum Y\u00f6netiminde G\u00fc\u00e7l\u00fc Bir Ara\u00e7"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/37705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=37705"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/37705\/revisions"}],"predecessor-version":[{"id":37706,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/37705\/revisions\/37706"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=37705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=37705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=37705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}