mobxjs/mobx · warning

${msg}

Error message

${msg}

What it means

useDeprecated is a helper that warns once per unique message via console.warn when a deprecated mobx-react-lite API is called. It is not an exception — the message text passed in describes which API is deprecated and what to use instead, and the warning is deduplicated so it appears only the first time.

Source

Thrown at packages/mobx-react-lite/src/utils/utils.ts:6

const deprecatedMessages: string[] = []

export function useDeprecated(msg: string) {
    if (!deprecatedMessages.includes(msg)) {
        deprecatedMessages.push(msg)
        console.warn(msg)
    }
}

View on GitHub (pinned to 01211a698b)

Solutions

  1. Follow the message: replace the deprecated call with the suggested modern API (usually observer() or useLocalObservable)
  2. Replace useObserver(fn) with wrapping the component in observer()
  3. Remove stale options arguments to observer() and hoist dependent observables with useLocalObservable
  4. Suppress only temporarily by filtering console.warn, but prefer migrating

Example fix

// before
function Comp(props) { return useObserver(() => <div>{props.name}</div>) }
// after
const Comp = observer(({ name }) => <div>{name}</div>)
Defensive patterns

Strategy: fallback

Validate before calling

null

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Calling deprecated mobx-react-lite exports such as useObserver() or observer(..., options) forms that have been superseded (e.g. by observer() without options or useLocalObservable), in a version where useDeprecated is wired to that export.

Common situations: Upgrading mobx-react-lite after 6.x where useObserver was replaced by direct observer()/React.mergeRenderless usage; copy-pasting old tutorial code; e2e logs showing one-time deprecation warnings.

Related errors


AI-assisted analysis of mobxjs/mobx@01211a698b (2026-08-28). Data as JSON: /api/errors/98ebc36c25bc25e2. Report an issue: GitHub.