{"record":{"id":"6c67aba2eeacff90","repo":"facebook/react","slug":"438","errorCode":"438","errorMessage":"An unsupported type was passed to use(): ","messagePattern":"An unsupported type was passed to use\\(\\): ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-reconciler/src/ReactFiberHooks.js","lineNumber":1178,"sourceCode":"  // $FlowFixMe[invalid-compare]\n  if (usable !== null && typeof usable === 'object') {\n    // $FlowFixMe[method-unbinding]\n    if (typeof usable.then === 'function') {\n      // This is a thenable.\n      const thenable: Thenable<T> = usable as any;\n      return useThenable(thenable);\n    } else if (usable.$$typeof === REACT_RECOVERABLE_TYPE) {\n      // Fiber is the final renderer, so there is no downstream host that\n      // needs to recover this subtree. Continue rendering through it.\n      return undefined as any;\n    } else if (usable.$$typeof === REACT_CONTEXT_TYPE) {\n      const context: ReactContext<T> = usable as any;\n      return readContext(context);\n    }\n  }\n\n  // eslint-disable-next-line react-internal/safe-string-coercion\n  throw new Error('An unsupported type was passed to use(): ' + String(usable));\n}\n\nfunction useMemoCache(size: number): Array<mixed> {\n  let memoCache = null;\n  // Fast-path, load memo cache from wip fiber if already prepared\n  let updateQueue: FunctionComponentUpdateQueue | null =\n    currentlyRenderingFiber.updateQueue as any;\n  if (updateQueue !== null) {\n    memoCache = updateQueue.memoCache;\n  }\n  // Otherwise clone from the current fiber\n  if (memoCache == null) {\n    const current: Fiber | null = currentlyRenderingFiber.alternate;\n    if (current !== null) {\n      const currentUpdateQueue: FunctionComponentUpdateQueue | null =\n        current.updateQueue as any;\n      if (currentUpdateQueue !== null) {\n        const currentMemoCache: ?MemoCache = currentUpdateQueue.memoCache;","sourceCodeStart":1160,"sourceCodeEnd":1196,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-reconciler/src/ReactFiberHooks.js#L1160-L1196","documentation":"use() accepts exactly three kinds of values: a thenable (Promise), a React Context (REACT_CONTEXT_TYPE), or a recoverable error value (REACT_RECOVERABLE_TYPE). Anything else — primitives, plain objects, undefined — falls through the checks and throws this error, with the offending value stringified into the message.","triggerScenarios":"Calling use() with a non-promise variable (a value that was already awaited, a plain object, a number/boolean/undefined), or a Promise polyfill/mock whose `then` isn't a function so the thenable check misses.","commonSituations":"Typos like use(promiseResults) instead of the promise itself; passing a context provider instead of the context; libraries handing use() a lookalike thenable; unwrapping optional values (`use(context?.something)`).","solutions":["Pass the Promise itself (not its resolved value) or the context object created by createContext.","Narrow before calling: check `isThenable` (typeof value?.then === 'function') or `$$typeof` for contexts when the value's shape is uncertain.","If a mock/polyfill promise fails the thenable check, use a real Promise (Promise.resolve()) in tests."],"exampleFix":"// before\nconst data = use(fetchData());       // fetchData returns a plain value\nconst theme = use(ThemeContext.Provider); // provider, not context\n\n// after\nconst data = use(fetchDataPromise()); // the Promise itself\nconst theme = use(ThemeContext);       // the context object","handlingStrategy":"type-guard","validationCode":"// Validate the argument before calling use()\nfunction isThenable(v) {\n  return v !== null && typeof v === 'object' && typeof v.then === 'function';\n}\nconst value = isThenable(maybePromise)\n  ? use(maybePromise)\n  : maybePromise; // already-resolved value or safe default","typeGuard":"const REACT_CONTEXT = Symbol.for('react.context');\nfunction isUsable(v) {\n  if (v == null) return false;\n  if (typeof v === 'object' && typeof v.then === 'function') return true;\n  return typeof v === 'object' && v.$$typeof === REACT_CONTEXT;\n}","tryCatchPattern":"// Wrap risky use() calls during data-layer migrations\ntry {\n  value = use(maybeResource);\n} catch (err) {\n  if (/unsupported type was passed to use/.test(err.message)) {\n    return fallbackValue; // and log the String(usable) the message includes\n  }\n  throw err;\n}","preventionTips":["Pass only the Promise itself or a createContext() object to use()","Type the parameter as Promise<T> | React.Context<T> so the compiler rejects junk","In tests, use real Promises (Promise.resolve()) not thenable lookalikes"],"tags":["hooks","use-api","suspense","type-validation"],"backgroundTag":"invalid-hook-argument","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}