{"record":{"id":"b90c6114a87188d4","repo":"Meituan-Dianping/mpvue","slug":"avoid-mutating-an-injected-value-directly-since-th-b90c61","errorCode":null,"errorMessage":"Avoid mutating an injected value directly since the changes will be overwritten whenever the provided component re-renders. injection being mutated: \"${key}\"","messagePattern":"Avoid mutating an injected value directly since the changes will be overwritten whenever the provided component re-renders\\. injection being mutated: \"(.+?)\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/instance/inject.js","lineNumber":25,"sourceCode":"\nexport function initProvide (vm: Component) {\n  const provide = vm.$options.provide\n  if (provide) {\n    vm._provided = typeof provide === 'function'\n      ? provide.call(vm)\n      : provide\n  }\n}\n\nexport function initInjections (vm: Component) {\n  const result = resolveInject(vm.$options.inject, vm)\n  if (result) {\n    observerState.shouldConvert = false\n    Object.keys(result).forEach(key => {\n      /* istanbul ignore else */\n      if (process.env.NODE_ENV !== 'production') {\n        defineReactive(vm, key, result[key], () => {\n          warn(\n            `Avoid mutating an injected value directly since the changes will be ` +\n            `overwritten whenever the provided component re-renders. ` +\n            `injection being mutated: \"${key}\"`,\n            vm\n          )\n        })\n      } else {\n        defineReactive(vm, key, result[key])\n      }\n    })\n    observerState.shouldConvert = true\n  }\n}\n\nexport function resolveInject (inject: any, vm: Component): ?Object {\n  if (inject) {\n    // inject is :any because flow is not smart enough to figure out cached\n    const result = Object.create(null)","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/core/instance/inject.js#L7-L43","documentation":"Fires from a reactive getter callback installed by defineReactive on injected keys during initInjections. Each inject binding on the component instance is made reactive specifically so that any assignment to it (e.g. this.myInjected = x) triggers this warning: injected values are read-only conduits from an ancestor's provide, and because the injection is re-resolved from the provider whenever it re-renders, local mutations are silently discarded.","triggerScenarios":"Thrown at src/core/instance/inject.js:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the mutated value into local data initialized from the injection: data() { return { local: this.myInjected } }","Declare a computed property that wraps the injected value and derives changed state from it","If two-way flow is needed, inject a mutable object or a setter method from the provider and mutate that object's properties instead of the binding itself"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}