Closed efoken closed 3 weeks ago
Just used this as a workaround for now, seems to work:
datePicker.props = {
value: createType((value) => (value instanceof Date ? value : new Date(value))),
}
Hi @efoken , sorry for not responding earlier. Atomico has improved the types by allowing transformations by instance if it is not covered by Atomico, but this only covers inputs as attributes.
To force Atomico to allow input via attributes, you can use the "$" prefix, for example:
<my-component $date="2023-03-11"/>
... Now I think it would be useful in the future to add logic that allows working together with props that have both string and non-string inputs. For example, if the type is declared as Number and it receives "0"
, the output would be 0
. What do you think about what was mentioned?
Describe the bug I'm getting error
The value defined for prop 'value' must be of type 'Date'
when passing a string to a prop of type Date. Shouldn't it be parsed the Date object when a string is given since 1.73.0?I tried this within Storybook.
Here's my simplified DatePicker component:
Browser (please complete the following information):
To Reproduce Steps to reproduce the behavior:
value
prop of typeDate
<my-date-picker value="2023-09-22">
Expected behavior String value should be parsed to a Date.