{"id":101,"date":"2025-01-28T04:53:56","date_gmt":"2025-01-28T04:53:56","guid":{"rendered":"https:\/\/techkubo.com\/react\/?p=101"},"modified":"2025-05-19T10:14:04","modified_gmt":"2025-05-19T10:14:04","slug":"react-usecontext-hook","status":"publish","type":"post","link":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/","title":{"rendered":"React useContext Hook"},"content":{"rendered":"\n<p>React Context provides a way to manage state globally across a component tree. It can be used in conjunction with the <code>useState<\/code> Hook to share state between deeply nested components more efficiently than using <code>useState<\/code> alone.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Challenge<\/h2>\n\n\n\n<p>State should be managed by the highest parent component in the component hierarchy that needs access to the state. To illustrate, consider a scenario where we have several nested components. The topmost component and the bottommost component both need access to the state.<\/p>\n\n\n\n<p>Without Context, we would have to pass the state as &#8220;props&#8221; through every nested component, a process known as &#8220;prop drilling&#8221;.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example<\/strong><\/h4>\n\n\n\n<p>Passing &#8220;props&#8221; through nested components:<\/p>\n\n\n\n<p>In this example, even though components 1-3 don&#8217;t need the state, they still have to pass it along to reach the final component.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">import { useState } from &quot;react&quot;;\nimport ReactDOM from &quot;react-dom\/client&quot;;\n\nfunction MainComponent() {\n  const [user, setUser] = useState(&quot;Alex Johnson&quot;);\n\n  return (\n    &lt;&gt;\n      &lt;h1&gt;{`Hello ${user}!`}&lt;\/h1&gt;\n      &lt;IntermediateComponent1 user={user} \/&gt;\n    &lt;\/&gt;\n  );\n}\n\nfunction IntermediateComponent1({ user }) {\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Intermediate Component 1&lt;\/h1&gt;\n      &lt;IntermediateComponent2 user={user} \/&gt;\n    &lt;\/&gt;\n  );\n}\n\nfunction IntermediateComponent2({ user }) {\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Intermediate Component 2&lt;\/h1&gt;\n      &lt;IntermediateComponent3 user={user} \/&gt;\n    &lt;\/&gt;\n  );\n}\n\nfunction IntermediateComponent3({ user }) {\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Intermediate Component 3&lt;\/h1&gt;\n      &lt;FinalComponent user={user} \/&gt;\n    &lt;\/&gt;\n  );\n}\n\nfunction FinalComponent({ user }) {\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Final Component&lt;\/h1&gt;\n      &lt;h2&gt;{`Hello ${user} again!`}&lt;\/h2&gt;\n    &lt;\/&gt;\n  );\n}\n\nconst root = ReactDOM.createRoot(document.getElementById('root'));\nroot.render(&lt;MainComponent \/&gt;);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating Context<\/h2>\n\n\n\n<p>The solution is to create a Context. To create a Context, import <code>createContext<\/code> and initialize it:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">import { useState, createContext } from &quot;react&quot;;\nimport ReactDOM from &quot;react-dom\/client&quot;;\n\nconst UserContext = createContext();<\/pre><\/div>\n\n\n\n<p>Next, use the Context Provider to wrap the components that need access to the state.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Context Provider<\/h2>\n\n\n\n<p>Wrap child components with the Context Provider and supply the state value:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">function MainComponent() {\n  const [user, setUser] = useState(&quot;Alex Johnson&quot;);\n\n  return (\n    &lt;UserContext.Provider value={user}&gt;\n      &lt;h1&gt;{`Hello ${user}!`}&lt;\/h1&gt;\n      &lt;IntermediateComponent1 \/&gt;\n    &lt;\/UserContext.Provider&gt;\n  );\n}<\/pre><\/div>\n\n\n\n<p>Now, all components within this tree will have access to the user Context.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using the useContext Hook<\/h2>\n\n\n\n<p>To access the Context in a child component, use the <code>useContext<\/code> Hook.<\/p>\n\n\n\n<p>First, include <code>useContext<\/code> in your import statement:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">import { useState, createContext, useContext } from &quot;react&quot;;<\/pre><\/div>\n\n\n\n<p>Then access the user Context in any component:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">function FinalComponent() {\n  const user = useContext(UserContext);\n\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Final Component&lt;\/h1&gt;\n      &lt;h2&gt;{`Hello ${user} again!`}&lt;\/h2&gt;\n    &lt;\/&gt;\n  );\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Full Example<\/h2>\n\n\n\n<p>A complete example using React Context:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">import { useState, createContext, useContext } from &quot;react&quot;;\nimport ReactDOM from &quot;react-dom\/client&quot;;\n\nconst UserContext = createContext();\n\nfunction MainComponent() {\n  const [user, setUser] = useState(&quot;Alex Johnson&quot;);\n\n  return (\n    &lt;UserContext.Provider value={user}&gt;\n      &lt;h1&gt;{`Hello ${user}!`}&lt;\/h1&gt;\n      &lt;IntermediateComponent1 \/&gt;\n    &lt;\/UserContext.Provider&gt;\n  );\n}\n\nfunction IntermediateComponent1() {\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Intermediate Component 1&lt;\/h1&gt;\n      &lt;IntermediateComponent2 \/&gt;\n    &lt;\/&gt;\n  );\n}\n\nfunction IntermediateComponent2() {\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Intermediate Component 2&lt;\/h1&gt;\n      &lt;IntermediateComponent3 \/&gt;\n    &lt;\/&gt;\n  );\n}\n\nfunction IntermediateComponent3() {\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Intermediate Component 3&lt;\/h1&gt;\n      &lt;FinalComponent \/&gt;\n    &lt;\/&gt;\n  );\n}\n\nfunction FinalComponent() {\n  const user = useContext(UserContext);\n\n  return (\n    &lt;&gt;\n      &lt;h1&gt;Final Component&lt;\/h1&gt;\n      &lt;h2&gt;{`Hello ${user} again!`}&lt;\/h2&gt;\n    &lt;\/&gt;\n  );\n}\n\nconst root = ReactDOM.createRoot(document.getElementById('root'));\nroot.render(&lt;MainComponent \/&gt;);<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>React Context provides a way to manage state globally across a component tree. It can be used in conjunction with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-101","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>React useContext Hook - React Tutorial<\/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:\/\/techkubo.com\/react\/react-usecontext-hook\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React useContext Hook - React Tutorial\" \/>\n<meta property=\"og:description\" content=\"React Context provides a way to manage state globally across a component tree. It can be used in conjunction with [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/\" \/>\n<meta property=\"og:site_name\" content=\"React Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-28T04:53:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-19T10:14:04+00:00\" \/>\n<meta name=\"author\" content=\"Manong\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Manong\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/\"},\"author\":{\"name\":\"Manong\",\"@id\":\"https:\/\/techkubo.com\/react\/#\/schema\/person\/b4fa2f01fa4ff2a4e98276ce47115965\"},\"headline\":\"React useContext Hook\",\"datePublished\":\"2025-01-28T04:53:56+00:00\",\"dateModified\":\"2025-05-19T10:14:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/\"},\"wordCount\":229,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/techkubo.com\/react\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/\",\"url\":\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/\",\"name\":\"React useContext Hook - React Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/techkubo.com\/react\/#website\"},\"datePublished\":\"2025-01-28T04:53:56+00:00\",\"dateModified\":\"2025-05-19T10:14:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/techkubo.com\/react\/react-usecontext-hook\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/techkubo.com\/react\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React useContext Hook\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/techkubo.com\/react\/#website\",\"url\":\"https:\/\/techkubo.com\/react\/\",\"name\":\"React Tutorial\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/techkubo.com\/react\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/techkubo.com\/react\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/techkubo.com\/react\/#organization\",\"name\":\"React Tutorial\",\"url\":\"https:\/\/techkubo.com\/react\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techkubo.com\/react\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/techkubo.com\/react\/wp-content\/uploads\/sites\/10\/2025\/04\/cropped-cropped-Techkubo-logo-1-300x220-1.png\",\"contentUrl\":\"https:\/\/techkubo.com\/react\/wp-content\/uploads\/sites\/10\/2025\/04\/cropped-cropped-Techkubo-logo-1-300x220-1.png\",\"width\":300,\"height\":220,\"caption\":\"React Tutorial\"},\"image\":{\"@id\":\"https:\/\/techkubo.com\/react\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/techkubo.com\/react\/#\/schema\/person\/b4fa2f01fa4ff2a4e98276ce47115965\",\"name\":\"Manong\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techkubo.com\/react\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/21a7455736c21887b8fefe0935012d65?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/21a7455736c21887b8fefe0935012d65?s=96&d=mm&r=g\",\"caption\":\"Manong\"},\"sameAs\":[\"https:\/\/techkubo.com\"],\"url\":\"https:\/\/techkubo.com\/react\/author\/manong\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"React useContext Hook - React Tutorial","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:\/\/techkubo.com\/react\/react-usecontext-hook\/","og_locale":"en_US","og_type":"article","og_title":"React useContext Hook - React Tutorial","og_description":"React Context provides a way to manage state globally across a component tree. It can be used in conjunction with [&hellip;]","og_url":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/","og_site_name":"React Tutorial","article_published_time":"2025-01-28T04:53:56+00:00","article_modified_time":"2025-05-19T10:14:04+00:00","author":"Manong","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Manong","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/#article","isPartOf":{"@id":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/"},"author":{"name":"Manong","@id":"https:\/\/techkubo.com\/react\/#\/schema\/person\/b4fa2f01fa4ff2a4e98276ce47115965"},"headline":"React useContext Hook","datePublished":"2025-01-28T04:53:56+00:00","dateModified":"2025-05-19T10:14:04+00:00","mainEntityOfPage":{"@id":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/"},"wordCount":229,"commentCount":0,"publisher":{"@id":"https:\/\/techkubo.com\/react\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techkubo.com\/react\/react-usecontext-hook\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/","url":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/","name":"React useContext Hook - React Tutorial","isPartOf":{"@id":"https:\/\/techkubo.com\/react\/#website"},"datePublished":"2025-01-28T04:53:56+00:00","dateModified":"2025-05-19T10:14:04+00:00","breadcrumb":{"@id":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techkubo.com\/react\/react-usecontext-hook\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/techkubo.com\/react\/react-usecontext-hook\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techkubo.com\/react\/"},{"@type":"ListItem","position":2,"name":"React useContext Hook"}]},{"@type":"WebSite","@id":"https:\/\/techkubo.com\/react\/#website","url":"https:\/\/techkubo.com\/react\/","name":"React Tutorial","description":"","publisher":{"@id":"https:\/\/techkubo.com\/react\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techkubo.com\/react\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techkubo.com\/react\/#organization","name":"React Tutorial","url":"https:\/\/techkubo.com\/react\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techkubo.com\/react\/#\/schema\/logo\/image\/","url":"https:\/\/techkubo.com\/react\/wp-content\/uploads\/sites\/10\/2025\/04\/cropped-cropped-Techkubo-logo-1-300x220-1.png","contentUrl":"https:\/\/techkubo.com\/react\/wp-content\/uploads\/sites\/10\/2025\/04\/cropped-cropped-Techkubo-logo-1-300x220-1.png","width":300,"height":220,"caption":"React Tutorial"},"image":{"@id":"https:\/\/techkubo.com\/react\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/techkubo.com\/react\/#\/schema\/person\/b4fa2f01fa4ff2a4e98276ce47115965","name":"Manong","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techkubo.com\/react\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/21a7455736c21887b8fefe0935012d65?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21a7455736c21887b8fefe0935012d65?s=96&d=mm&r=g","caption":"Manong"},"sameAs":["https:\/\/techkubo.com"],"url":"https:\/\/techkubo.com\/react\/author\/manong\/"}]}},"_links":{"self":[{"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/posts\/101"}],"collection":[{"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":2,"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/posts\/101\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techkubo.com\/react\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}