From 6c16abcd81957ff1ec0fd8a01986fde9ca6fecb5 Mon Sep 17 00:00:00 2001 From: Nabeel-akk Date: Fri, 27 Nov 2026 09:11:38 +0500 Subject: [PATCH] docs(useContext): explain separate providers in troubleshooting --- src/content/reference/react/useContext.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/reference/react/useContext.md b/src/content/reference/react/useContext.md index 022277df40f..91865f7e413 100644 --- a/src/content/reference/react/useContext.md +++ b/src/content/reference/react/useContext.md @@ -1352,6 +1352,7 @@ There are a few common ways that this can happen: 1. You're rendering `` in the same component (or below) as where you're calling `useContext()`. Move `` *above and outside* the component calling `useContext()`. 2. You may have forgotten to wrap your component with ``, or you might have put it in a different part of the tree than you thought. Check whether the hierarchy is right using [React DevTools.](/learn/react-developer-tools) 3. You might be running into some build issue with your tooling that causes `SomeContext` as seen from the providing component and `SomeContext` as seen by the reading component to be two different objects. This can happen if you use symlinks, for example. You can verify this by assigning them to globals like `window.SomeContext1` and `window.SomeContext2` and then checking whether `window.SomeContext1 === window.SomeContext2` in the console. If they're not the same, fix that issue on the build tool level. +4. You might have two separate providers of the same context. Each `` provider has its own independent value, so components inside one provider won't see updates from another. If both trees need the same value, render a single provider above both of them. ### I am always getting `undefined` from my context although the default value is different {/*i-am-always-getting-undefined-from-my-context-although-the-default-value-is-different*/}