You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[2.0] createContext(undefined) throws ContextNotFoundError, even when a provider passes undefined #4181
So createContext<T | undefined>(undefined), the most common optional-context idiom in React and Solid 1 (where useContext returned undefined), throws when read outside a provider. It also throws when a provider explicitly passes undefined. Inside a computation, the throw halts reactivity for the whole app (#4178).
The message, "Context must either be created with a default value or a value must be provided before accessing it", sounds wrong when the caller did pass a default.
Distinguish "no default argument" from an explicit undefined default (arguments.length or a sentinel), and throw only for the former.
Treat a provider's explicit value={undefined} as a provided value.
If that's not wanted, at minimum say in the error message and the docs/cheatsheet that undefined counts as missing, and that null is the way to make a context optional.
Screenshots or Videos
No response
Platform
OS: macOS (Darwin 25.5)
Browser: n/a (reproduced in Node v24.18.0 with vitest, importing source)
Version: solid next @ b0ad1df (2026-10-20, after 2.0.0-rc.16)
Additional context
This came up while verifying examples for the From React docs additions (solidjs/solid-docs#1664). It's also a silent migration break from 1.x, where useContext returned undefined.
changed the title [-][2.0] throws ContextNotFoundError, even when a provider passes [/-][+][2.0] `createContext(undefined)` throws ContextNotFoundError, even when a provider passes `undefined`[/+]on Oct 21, 2026
Activity
[-][2.0] throws ContextNotFoundError, even when a provider passes [/-][+][2.0] `createContext(undefined)` throws ContextNotFoundError, even when a provider passes `undefined`[/+]fix(signals,solid): explain undefined context values in the dev Conte…
ryansolid commentedon Oct 21, 2026
Generated by Claude Code