()
| 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 | } |
no test coverage detected