Open lucywang000 opened 4 years ago
Hmm. To add more context, I don't believe that nil
is a valid :value
for most DOM elements, hence the reason that we would prefer to coerce nil
to js/undefined
when used with DOM elements.
Clearly, this is too prescriptive in the general case of working with 3rd party components (or native components of other reconcilers). I'll have to think about the best way to solve this; my hunch is that we should distinguish between transforms necessary for "native" elements, and transforms necessary for DOM elements.
After this commit, when the
:value
prop isnil
, helix would replace it withundefined
. But in react components likeinput
etc. with:value nil
is treated as a controlled component, while:value undefined
is treated as uncontrolled.This is a problem e.g. when using the
Autocomplete
component of material-ui, the:value
prop must be eithernil
or one of the values in the options list. However when I try to give it anil
, helix changes it toundefined
, which effectively make this component a uncontrolled one. Later when the user chooses a value from the auto complete list, the component would become a controlled element and cause errors.