{"record":{"id":"2795d3b9b7c3248b","repo":"mobxjs/mobx","slug":"mobx-derivation-derivation-name-is-created","errorCode":null,"errorMessage":"[mobx] Derivation '${derivation.name_}' is created/updated without reading any observable value.","messagePattern":"\\[mobx\\] Derivation '(.+?)' is created/updated without reading any observable value\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/mobx/src/core/derivation.ts","lineNumber":215,"sourceCode":"    }\n    return result\n}\n\nfunction warnAboutDerivationWithoutDependencies(derivation: IDerivation) {\n    if (!__DEV__) {\n        return\n    }\n\n    if (derivation.observing_.length !== 0) {\n        return\n    }\n\n    if (\n        typeof derivation.requiresObservable_ === \"boolean\"\n            ? derivation.requiresObservable_\n            : globalState.reactionRequiresObservable\n    ) {\n        console.warn(\n            `[mobx] Derivation '${derivation.name_}' is created/updated without reading any observable value.`\n        )\n    }\n}\n\n/**\n * diffs newObserving with observing.\n * update observing to be newObserving with unique observables\n * notify observers that become observed/unobserved\n */\nfunction bindDependencies(derivation: IDerivation) {\n    // invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, \"INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1\");\n    const prevObserving = derivation.observing_\n    const observing = (derivation.observing_ = derivation.newObserving_!)\n    let lowestNewObservingDerivationState = IDerivationState_.UP_TO_DATE_\n\n    // Go through all new observables and check diffValue: (this list can contain duplicates):\n    //   0: first occurrence, change to 1 and keep it","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/mobxjs/mobx/blob/01211a698b64ea94de8e5f276ff8235fcf8ddf96/packages/mobx/src/core/derivation.ts#L197-L233","documentation":"warnAboutDerivationWithoutDependencies fires when a derivation (computed or reaction body) completes tracking without reading any observable. Because it depends on nothing it will never re-run, which is almost always a bug, so MobX warns when reactionRequiresObservable is globally enabled or the derivation has requiresObservable_ set.","triggerScenarios":"Creating a reaction()/autorun() whose body reads no observables (e.g. reading plain JS fields, or reading before data is set up), or a computed that returns a constant, while configure({ reactionRequiresObservable: true }) or with requiresObservable: true on the decorator/observable options.","commonSituations":"Typo in property names inside a reaction body; reading from a plain (non-observable) object; reaction bodies guarded by an early return before any observable read; new teams enabling reactionRequiresObservable and hitting legacy reactions.","solutions":["Make the derivation read at least one observable, or remove it if it needs no reactive inputs.","Fix typos/wrong references so the body actually touches observable properties.","Disable the global flag if intentional: configure({ reactionRequiresObservable: false }).","For conditional bodies, hoist an observable read (e.g. store.ready) above the early return.","Pass requiresObservable: true selectively only on derivations that must have deps."],"exampleFix":"// before\nautorun(() => {\n  if (store.items.length === 0) return // fine, but reads nothing when guarded\n  render(normalize(store.items))\n})\n\n// after\nautorun(() => {\n  const items = store.items // observable read first\n  if (items.length === 0) return\n  render(normalize(items))\n})","handlingStrategy":"validation","validationCode":"import { configure } from 'mobx'\n// guard: every reaction body must read at least one observable\n// configure({ reactionRequiresObservable: false }) // if legacy reactions read conditionally\nfunction validateReactionBody(body) {\n  const deps = new Set()\n  const proxied = new Proxy(body, {})\n  // simplest practical check: run under autorun with spy and assert an update event fires\n  return typeof body === 'function' && body.length === 0\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read all needed observables before any early return in a reaction body.","Never read plain (non-observable) state inside derivations and expect re-runs.","Enable reactionRequiresObservable only for new, disciplined code."],"tags":["mobx","derivation","no-dependencies","reaction","config"],"backgroundTag":"derivation-without-observable-dependencies","analyzedSha":"01211a698b64ea94de8e5f276ff8235fcf8ddf96","analyzedAt":"2026-08-28T22:10:08.831Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}