We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 41fa6c1 commit 9f6e6b3Copy full SHA for 9f6e6b3
1 file changed
packages/solid/src/reactive/signal.ts
@@ -1201,9 +1201,11 @@ export function createContext<T>(
1201
*/
1202
export function useContext<T>(context: Context<T>): T {
1203
let value: undefined | T;
1204
- return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
1205
- ? value
1206
- : context.defaultValue;
+ let ctx = Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
+ ? value
+ : context.defaultValue;
1207
+ IS_DEV && !ctx && console.warn("`useContext` returns null. Is it being called inside a provider?")
1208
+ return ctx;
1209
}
1210
1211
export type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement>;
0 commit comments