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
- Follow the message: replace the deprecated call with the suggested modern API (usually observer() or useLocalObservable)
- Replace useObserver(fn) with wrapping the component in observer()
- Remove stale options arguments to observer() and hoist dependent observables with useLocalObservable
- 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
- Track mobx-react-lite changelogs when upgrading
- Replace useObserver with observer() wrapping
- Migrate options-argument observer calls to useLocalObservable
- Treat deprecation warnings as CI failures to force migration
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
- [mobx-react-lite] You are trying to use `observer` on a func
- [mobx-react-lite] `render` property of ForwardRef was not a
- mobx-react-lite requires React 18 or later
- mobx-react-lite requires mobx at least version 7 to be avail
- WARNING: Debug feature only. MobX will NOT recover from erro
AI-assisted analysis of mobxjs/mobx@01211a698b (2026-08-28).
Data as JSON: /api/errors/98ebc36c25bc25e2.
Report an issue: GitHub.