Capítulo 80 de 116
createContext(defaultValue) creates the Context object that a provider supplies a value for and useContext reads from — the constructor half of the Context mechanism whose usage was covered in Ch 32/50.
const SomeContext = createContext(defaultValue) — returns an object with a Provider-capable component (in modern React, the Context object itself is used directly as <SomeContext value={...}>) and serves as the identity useContext matches against.defaultValue is the fallback, used only when a consumer calls useContext(SomeContext) with no matching provider anywhere above it in the tree — not a "default until the real value loads" mechanism, and not used at all once any provider is present above a given consumer.createContext<T>(defaultValue) carries the value's type through to every useContext call site automatically — a common reason defaultValue is given a realistic shape (or null with the consuming code guarding against it) rather than an arbitrary placeholder.// theme-context.js — created once at module scope, imported wherever needed
export const ThemeContext = createContext('light');
defaultValue only applies with zero providers above the consumer — don't rely on it as a general fallback while a real provider is still initializing.