Subscribe on changes!

To be able to pass the `undefined` value to a prop

avatar
May 8th 2021

What problem does this feature solve?

Sometimes we have a prop which has non-undefined default value, and we want to allow people to override that prop with the undefined.

What does the proposed API look like?

https://codesandbox.io/s/hungry-herschel-3qvwg?file=/src/components/HelloWorld.vue

avatar
May 8th 2021

Passing undefined is the same as not passing a value to a prop and this is intended for practical reasons. Pass null instead if you want to signify an empty value for the prop. This would be a breaking change so it won't happen.

avatar
May 8th 2021

Thanks for your quick reply 👍 .

IMHO, if we have something like in operator or getOwnProperty method to distinguish that whether one prop is passed with undefined or just not be passed, then this will not introduce a breaking change I thought (but there may have another practical reasons I didn't know/understand, I just want to mention more details here for this feature request).

In addition, in real world, we may:

  1. Use the undefined to indicate that the value has not been initialized.
  2. Use the null to indicate that the value has been initialized or deleted.

And we want to use the null as default value for general cases, and pass the undefined to override that default value for some other scenarios.