-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Description
I have a component that let's user select an object from an array.
<comp :selected.sync="selectedObject">
// parent data
data: {
selectedObject: null
}
// comp prop
props: {
selected: {twoWay: true, type: Object}
}
and in parent template I have something like
<div v-if="selectedObject"> blah blah blah </div>
<div v-else> please select an object </div>
which displays different content based on whether an object is selected.
and I get
[Vue warn]: Invalid prop: type check failed for selected="selectedObject". Expected Object, got Null.
I know i can just remove the "type: Object" check and suppress the warning,
but wouldn't it be better if component props checks treat null as an object?
Because javascript does that (typeof null === 'object'),
and setting null as an initial value (to my knowledge) doesn't affect mutation observation.
Metadata
Metadata
Assignees
Labels
No labels