MCPcopy
hub / github.com/chakra-ui/ark / useContext

Function useContext

packages/react/src/utils/create-context.ts:33–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 Context.displayName = name
32
33 function useContext() {
34 const context = useReactContext(Context)
35
36 if (!context && strict) {
37 const error = new Error(errorMessage ?? getErrorMessage(hookName, providerName))
38 error.name = 'ContextError'
39 if (hasProp(Error, 'captureStackTrace') && isFunction(Error.captureStackTrace)) {
40 Error.captureStackTrace(error, useContext)
41 }
42 throw error
43 }
44
45 return context
46 }
47
48 return [Context.Provider, useContext, Context] as CreateContextReturn<T>
49}

Callers 2

useDrawerStackStoreFunction · 0.90
withContextFunction · 0.90

Calls 2

isFunctionFunction · 0.90
getErrorMessageFunction · 0.70

Tested by

no test coverage detected