Meituan-Dianping/mpvue · error
Invalid default value for prop "${key}": Props with type Obj
Error message
Invalid default value for prop "${key}": Props with type Object/Array must use a factory function to return the default value. What it means
Raised in getPropDefaultValue during prop validation when the prop declares a 'default' whose value isObject(def) — i.e. a plain object or array literal. Object/Array defaults are shared by reference across all instances of the component, so one instance mutating the default would leak into every other instance; Vue requires a factory function whose fresh return value is used per instance. The object default is still used (called as-is if a function, otherwise passed through), but the shared-reference hazard remains.
Source
Thrown at src/core/util/props.js:64
}
if (process.env.NODE_ENV !== 'production') {
assertProp(prop, key, value, vm, absent)
}
return value
}
/**
* Get the default value of a prop.
*/
function getPropDefaultValue (vm: ?Component, prop: PropOptions, key: string): any {
// no default, return undefined
if (!hasOwn(prop, 'default')) {
return undefined
}
const def = prop.default
// warn against non-factory defaults for Object & Array
if (process.env.NODE_ENV !== 'production' && isObject(def)) {
warn(
'Invalid default value for prop "' + key + '": ' +
'Props with type Object/Array must use a factory function ' +
'to return the default value.',
vm
)
}
// the raw prop value was also undefined from previous render,
// return previous default value to avoid unnecessary watcher trigger
if (vm && vm.$options.propsData &&
vm.$options.propsData[key] === undefined &&
vm._props[key] !== undefined
) {
return vm._props[key]
}
// call factory function for non-Function types
// a value is Function if its prototype is function even across different execution context
return typeof def === 'function' && getType(prop.type) !== 'Function'
? def.call(vm)View on GitHub (pinned to 6c5d78ee04)
Solutions
- Use a factory function for object/array defaults: props: { items: { type: Array, default: () => [] } } or default() { return { a: 1 } }
- Scalar defaults (String, Number, Boolean) may stay as plain values
- Audit shared default objects for in-place mutation; move all mutation to per-instance data copies
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/core/util/props.js:64 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02).
Data as JSON: /api/errors/88f32939689854b2.
Report an issue: GitHub.