{"record":{"id":"53ad5e6082462472","repo":"mobxjs/mobx","slug":"mobx-computed-value-this-name-is-being-rea","errorCode":null,"errorMessage":"[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.","messagePattern":"\\[mobx\\] Computed value '(.+?)' is being read outside a reactive context\\. Doing a full recompute\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/mobx/src/core/computedvalue.ts","lineNumber":331,"sourceCode":"    }\n\n    suspend_() {\n        if (!this.keepAlive_) {\n            clearObserving(this)\n            this.value_ = undefined // don't hold on to computed value!\n        }\n    }\n\n    warnAboutUntrackedRead_() {\n        if (!__DEV__) {\n            return\n        }\n        if (\n            typeof this.requiresReaction_ === \"boolean\"\n                ? this.requiresReaction_\n                : globalState.computedRequiresReaction\n        ) {\n            console.warn(\n                `[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`\n            )\n        }\n    }\n\n    toString() {\n        return `${this.name_}[${this.derivation.toString()}]`\n    }\n\n    valueOf(): T {\n        return toPrimitive(this.get())\n    }\n\n    [Symbol.toPrimitive]() {\n        return this.valueOf()\n    }\n}\n","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/mobxjs/mobx/blob/01211a698b64ea94de8e5f276ff8235fcf8ddf96/packages/mobx/src/core/computedvalue.ts#L313-L349","documentation":"MobX computed values are cached and only recomputed when dependencies change inside a reactive context (reaction, render, autorun). If `computedRequiresReaction` (or the computed's `requiresReaction_` option) is enabled and a computed is read outside such a context, MobX warns that it must do an expensive full recompute instead of using the cache.","triggerScenarios":"Reading a computed property (e.g. `store.total`) outside any reaction/observer while `configure({ computedRequiresReaction: true })` is set, or that specific computed was created with `requiresReaction: true`.","commonSituations":"Reading observables in event handlers, setTimeout callbacks, tests, or during logging/debugging; enabling strict reaction checks in development to catch accidental untracked reads.","solutions":["Move the read inside a reaction: wrap it in `autorun`, `reaction`, `when`, or a React component's render with `observer`.","Use `untracked(() => store.total)` if the read is intentional and unreactive.","If the warning is noise for your app, disable it via `configure({ computedRequiresReaction: false })`."],"exampleFix":"// before\nfunction handleClick() { console.log(store.total) }\n// after\nfunction handleClick() {\n  untracked(() => console.log(store.total))\n}","handlingStrategy":"try-catch","validationCode":"import { configure } from 'mobx'\nconfigure({ computedRequiresReaction: true })\n// in dev/tests this surfaces any computed read happening outside a reaction\n// so the offending access can be fixed before it ships","typeGuard":"function isReadInsideReaction() {\n  try {\n    const gs = require('mobx')._getGlobalState()\n    return gs.trackingDerivation != null\n  } catch {\n    return true // internal API unavailable; assume safe\n  }\n}","tryCatchPattern":"import { untracked } from 'mobx'\nfunction safeReadComputed(store) {\n  try {\n    return store.total\n  } catch (e) {\n    return untracked(() => store.total)\n  }\n}","preventionTips":["Read computed values only inside autorun/reaction/observer render contexts","Use untracked() for deliberate one-off reads","Enable computedRequiresReaction in dev/tests to catch offenders early","Wrap event-handler reads of computeds in untracked or toJS"],"tags":["mobx","computed","reactivity","performance"],"backgroundTag":"computed-read-outside-reactive-context","analyzedSha":"01211a698b64ea94de8e5f276ff8235fcf8ddf96","analyzedAt":"2026-08-28T22:10:08.831Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}