admin管理员组文章数量:1406937
I am trying to add a DateInput to a form and set its value from the model value, which is a formatted string. I am trying to parse it according to the HeroUI doc:
<DateInput
className="max-w-sm"
label="Active from"
value={parseDate(activeFrom)}
</DateInput>
And get the following exception: Ts2322: CalendarDate is not assignable to type DateValue | null | undefined
The I tried to construct an object of the DateValue type and found out, that the @heroui/react does not have this type. I have the only dependency in my package.lock: "@heroui/react": "^2.6.14"
what dependencies do I need to add to obtain the DateValue type?
Thanks in advance!
I am trying to add a DateInput to a form and set its value from the model value, which is a formatted string. I am trying to parse it according to the HeroUI doc:
<DateInput
className="max-w-sm"
label="Active from"
value={parseDate(activeFrom)}
</DateInput>
And get the following exception: Ts2322: CalendarDate is not assignable to type DateValue | null | undefined
The I tried to construct an object of the DateValue type and found out, that the @heroui/react does not have this type. I have the only dependency in my package.lock: "@heroui/react": "^2.6.14"
what dependencies do I need to add to obtain the DateValue type?
Thanks in advance!
Share Improve this question asked Mar 7 at 15:57 Andrei IsakovAndrei Isakov 591 silver badge3 bronze badges1 Answer
Reset to default 0You need to install the @internationalized/date
dependency, as the DateValue
type is exported by it. Refer to heroui's documentation for details.
See the example:
import { DateInput } from "@heroui/react";
import type { DateValue } from "@internationalized/date";
import { CalendarDate, parseDate } from "@internationalized/date";
export default function App() {
return (
<DateInput
isReadOnly
defaultValue={parseDate("2024-04-04")}
label={"Birth date"}
placeholderValue={new CalendarDate(1995, 11, 6)}
/>
);
}
本文标签: reactjsHeroUI react does not have a DateValueStack Overflow
版权声明:本文标题:reactjs - HeroUI react does not have a DateValue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744919513a2632203.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论