Closed nickavignone closed 4 years ago
A work around people can use if they need to:
Pass a custom input component to DayPickerInput with the component property and have that input replace undefined with an empty string.
Works for me with 7.4.8
... thanks for the fix
General react question: does it matter whether we use null
or undefined
to reset the component?
@himat I recommend to use null
everywhere and ban undefined
from your code. This approach comes from a talk by Douglas Crockford who pointed out that we don't need two types of "not set" and should stick to one of them.
@redaxmedia Interestingly Douglas Crockford himself stopped using null
and only uses undefined
with the rationale that undefined is already used a lot internally in javascript.
Isn't it like this:
undefined
- not set
null
- set to nothing
I don't think you can really get rid of one or the other, they mean different things. If you get a model from API it's empty fields are set to null
, for example.
Trying to set dates to undefined to clear, causes the below error
A component is changing a controlled input of type undefined to be uncontrolled. Input elements should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component.