react-multi-date-picker icon indicating copy to clipboard operation
react-multi-date-picker copied to clipboard

Multi-range mode DatePicker value typing is invalid.

Open CoCreate-SMWLucasO opened this issue 2 years ago • 3 comments

When dealing with the multi-range mode of the DatePicker, the available value property does not change its allowed types.

Currently, the multi-range allows for the following:

export type Value =
    | Date
    | string
    | number
    | DateObject
    | Date[]
    | string[]
    | number[]
    | DateObject[]
    | null;

However, the multi-range makes use of the DateObject[][], Date[][], etc. types. This means that it is not possible to pass this 2D-array into the value property as follows:

                    <DatePicker
                      multiple
                      range
                      format="DD/MM/YYYY"
                      value={[[new Date(), new Date()], ...]}
                    />

It is currently necessary to add a ts-ignore, for this reason.

A possible solution could be to add the 2d-array type to the Value type, or to add a separate value type for multi-range mode date pickers.

It's a minor issue, but ts-ignore statements aren't the nicest to have in a code base.

Thank you for your contributions to OSS, we love this library.

CoCreate-SMWLucasO avatar May 03 '23 13:05 CoCreate-SMWLucasO

Thank you for reporting this issue. I will work on it.

shahabyazdi avatar May 04 '23 10:05 shahabyazdi

Hello, is the issue fixed? Asking because I have the same problem.

WlanKasper avatar Jan 22 '24 11:01 WlanKasper

It should be fixed in v4.5.1.

shahabyazdi avatar May 18 '24 12:05 shahabyazdi