You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When passing properties to a component, would you prefer that the properties are type checked and throw an exception in case of wrong type, or rather allow JavaScript to implicitly type coerce, i.e., causing a side effect?
In practice, type coercion would mean that if you pass a property to a component, e.g., value = 42, but the component wants it as a string, value is implicitly coerced to value = 42`` , and so the state of value is a string.
A Implicit Type Coercion
B Throw Exception
The text was updated successfully, but these errors were encountered:
virtual-dom used to do B when giving a number foo in h('p', foo), and people complained. It made a lot of sense to apply coercion for that case. That's why I vote for A but sometimes B. It depends.
When passing properties to a component, would you prefer that the properties are type checked and throw an exception in case of wrong type, or rather allow JavaScript to implicitly type coerce, i.e., causing a side effect?
In practice, type coercion would mean that if you pass a property to a component, e.g.,
value = 42
, but the component wants it as a string,value
is implicitly coerced tovalue =
42`` , and so the state ofvalue
is a string.The text was updated successfully, but these errors were encountered: