facebook/react · error · Error

438

438

Error message

An unsupported type was passed to use(): %s

What it means

use() supports thenables, React contexts, and on the server client references that resolve to contexts. Anything else - primitives, plain objects without a then method, null - falls through to the final branch and throws with the stringified value appended.

Source

Thrown at packages/react-server/src/ReactFlightHooks.js:165

      return trackUsedThenable(thenableState, thenable, index);
    } else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
      unsupportedContext();
    }
  }

  if (isClientReference(usable)) {
    const clientReference: any = usable;
    if (
      clientReference.value != null &&
      clientReference.value.$$typeof === REACT_CONTEXT_TYPE
    ) {
      // Show a more specific message since it's a common mistake.
      throw new Error('Cannot read a Client Context from a Server Component.');
    } else {
      throw new Error('Cannot use() an already resolved Client Reference.');
    }
  } else {
    throw new Error(
      // eslint-disable-next-line react-internal/safe-string-coercion
      'An unsupported type was passed to use(): ' + String(usable),
    );
  }
}

View on GitHub (pinned to eafeac097b)

Solutions

  1. Only call use() on values confirmed to be promises/thenables; otherwise await the value or use it directly.
  2. Narrow before calling: x && typeof x.then === 'function' ? use(x) : x.
  3. Fix the data flow so only promises or contexts can reach the use() call site.

Example fix

// before
const value = use(input ?? {fallback: true}); // plain object reaches use()

// after
const value = input != null ? use(input) : {fallback: true};
Defensive patterns

Strategy: type-guard

Validate before calling

const REACT_CONTEXT = Symbol.for('react.context');
function isUsable(x: unknown): boolean {
  if (!x) return false;
  if (typeof x === 'object' || typeof x === 'function') {
    if (typeof (x as any).then === 'function') return true; // thenable
    if ((x as any).$$typeof === REACT_CONTEXT) return true; // context
  }
  return false;
}
const value = isUsable(input) ? use(input) : input;

Type guard

function isThenable<T>(x: unknown): x is PromiseLike<T> {
  return !!x && typeof (x as PromiseLike<T>).then === 'function';
}
function isReactContext(x: unknown): boolean {
  return !!x && (x as any).$$typeof === Symbol.for('react.context');
}

Prevention

When it happens

Trigger: Calling use(42), use(null), use('text'), or use({a: 1}) from shared or server code; generic code like use(maybePromise ?? fallbackObject) where the fallback is not a thenable.

Common situations: Loosely-typed wrappers calling use() on unknown input; optional chains that silently produce undefined; data flows where a plain result object is mistaken for a promise.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/d32a4a7a4444b996. Report an issue: GitHub.