[英]Type 'DateRange<Date | null>' is not assignable to type 'ValueType'
i want to implement a calendar where the user will be able to select multiple full weeks.我想实现一个日历,用户将能够 select 多个整周。 i am using the library rsuite for that.
我正在为此使用图书馆 rsuite。 I want to pass inside the property value of dateRangePicker of rsuite the value "selectedDates" which is of type
我想在 rsuite 的 dateRangePicker 的属性值中传递类型为“selectedDates”的值
const [selectedDate, handleDateChange] = useState<DateRange<Date | null>>([checkIn, checkOut]);"
const checkIn = row.checkInDate ? row.checkInDate : null;
const checkOut = row.checkOutDate ? row.checkOutDate : null;
and i got the following error我收到以下错误
Type 'DateRange<Date |
键入'日期范围<日期 | null>' is not assignable to type 'ValueType'.
null>' 不可分配给类型“ValueType”。 Type at position 0 in source is not compatible with type at position 0 in target.
源中 position 0 处的类型与目标中 position 0 处的类型不兼容。 Type 'Date |
输入“日期 | null' is not assignable to type 'Date |
null' 不可分配给类型 'Date | undefined'.
不明确的'。 Type 'null' is not assignable to type 'Date |
类型 'null' 不能分配给类型 'Date | undefined'.ts(2322) common.d.ts(103, 3): The expected type comes from property 'value' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<DateRangePickerProps, any, any>> & Readonly<...> & Readonly<...>'
undefined'.ts(2322) common.d.ts(103, 3):预期的类型来自属性'value',它在类型'IntrinsicAttributes & IntrinsicClassAttributes<Component<DateRangePickerProps, any, any>> & Readonly< ...> & 只读<...>'
Can anyone help me solve that?谁能帮我解决这个问题?
UPDATE:更新:
with the valueType as i understand i can only pass Date |据我了解,使用 valueType 我只能通过 Date | undefined, but if I pass inside the value property of the daterangepicker an undifined, when i try to change month i got NaN dates and invalid dates (look image)
未定义,但是如果我在 daterangepicker 的 value 属性中传递一个未定义的,当我尝试更改月份时,我得到 NaN 日期和无效日期(看图片)
i want to implement a calendar where the user will be able to select multiple full weeks.我想实现一个日历,用户将能够 select 多个整周。 i am using the library rsuite for that.
我正在为此使用图书馆 rsuite。 I want to pass inside the property value of dateRangePicker of rsuite the value "selectedDates" which is of type
我想在 rsuite 的 dateRangePicker 的属性值中传递类型为“selectedDates”的值
const [selectedDate, handleDateChange] = useState<DateRange<Date | null>>([checkIn, checkOut]);"
const checkIn = row.checkInDate ? row.checkInDate : null;
const checkOut = row.checkOutDate ? row.checkOutDate : null;
and i got the following error我收到以下错误
Type 'DateRange<Date |
键入'日期范围<日期 | null>' is not assignable to type 'ValueType'.
null>' 不可分配给类型“ValueType”。 Type at position 0 in source is not compatible with type at position 0 in target.
源中 position 0 处的类型与目标中 position 0 处的类型不兼容。 Type 'Date |
输入“日期 | null' is not assignable to type 'Date |
null' 不可分配给类型 'Date | undefined'.
不明确的'。 Type 'null' is not assignable to type 'Date |
类型 'null' 不能分配给类型 'Date | undefined'.ts(2322) common.d.ts(103, 3): The expected type comes from property 'value' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<DateRangePickerProps, any, any>> & Readonly<...> & Readonly<...>'
undefined'.ts(2322) common.d.ts(103, 3):预期的类型来自属性'value',它在类型'IntrinsicAttributes & IntrinsicClassAttributes<Component<DateRangePickerProps, any, any>> & Readonly< ...> & 只读<...>'
Can anyone help me solve that?谁能帮我解决这个问题?
UPDATE:更新:
with the valueType as i understand i can only pass Date |据我了解,使用 valueType 我只能通过 Date | undefined, but if I pass inside the value property of the daterangepicker an undifined, when i try to change month i got NaN dates and invalid dates (look image)
未定义,但是如果我在 daterangepicker 的 value 属性中传递一个未定义的,当我尝试更改月份时,我得到 NaN 日期和无效日期(看图片)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.