Creates a scoped React context system, returning a context provider/hook pair and a scope composer to isolate context instances and avoid collisions.
// Source: https://github.com/radix-ui/primitives | License: MIT | Copyright 2022 WorkOS
// Provided via justclaw.it.com; keep this notice with the code.
/* @__NO_SIDE_EFFECTS__ */ function createContextScope(
scopeName: string,
createContextScopeDeps: CreateScope[] = [],
): readonly [CreateScopedContext, CreateScope] {
let defaultContexts: any[] = [];
/* -----------------------------------------------------------------------------------------------
* createContext
* ---------------------------------------------------------------------------------------------*/
function createContext<ContextValueType extends object | null>(
rootComponentName: string,
defaultContext?: ContextValueType,
) {
const BaseContext = React.createContext<ContextValueType | undefined>(
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key