react-day-picker icon indicating copy to clipboard operation
react-day-picker copied to clipboard

Hi! I'm not opening new issue because I think it can be somehow related with this one 🙂

Open BuhayovA opened this issue 1 year ago • 2 comments

Hi! I'm not opening new issue because I think it can be somehow related with this one 🙂

So, after updating to 8.3.1 this issue appeared: Screenshot 2022-10-05 at 12 00 00

mode and selectedDate comes from props. Their types are defined as follows:

mode?: 'single' | 'multiple' | 'range';
selectedDate: DatesType

(and DatesType: Date | Date[] | DateRange | undefined, where DateRange is imported from `react-day-picker)

At this point I ran out of ideas how to resolve this issue. The only solution that worked, was something like this:

{ mode === 'single' && <DayPicker mode='single' selected={selectedDate as Date | undefined} {...otherProps} /> }
{ mode === 'multiple' && <DayPicker mode='multiple' selected={selectedDate as Date[] | undefined} {...otherProps} /> }
{ mode === 'range' && <DayPicker mode='range' selected={selectedDate as DateRange | undefined} {...otherProps} /> }

but to be hones it doesn't look too clean.

Maybe you would know what is the issue here and if there is a better way to resolve it than the one I showed above?

Thanks in advance 😃

Originally posted by @bartlomiej-bykowy in https://github.com/gpbl/react-day-picker/discussions/1570#discussioncomment-3803763

BuhayovA avatar Jan 24 '24 13:01 BuhayovA

The problem still hasn't been fixed :(

BuhayovA avatar Jan 24 '24 13:01 BuhayovA

`import React from 'react' import { DateRange, DayPicker, DayPickerMultipleProps, DayPickerRangeProps, DayPickerSingleProps, } from 'react-day-picker'

export interface PickDateFieldProps { ... }

export interface DayPickerMultipleProps extends PickDateFieldProps { mode: 'multiple' selected?: Date[] onSelect?: (days?: Date[]) => void }

export interface DayPickerSingleProps extends PickDateFieldProps { mode: 'single' selected?: Date onSelect?: (day?: Date) => void }

export interface DayPickerRangeProps extends PickDateFieldProps { mode: 'range' selected?: DateRange onSelect?: (range?: DateRange) => void }

export type DatePickerProps = DayPickerMultipleProps | DayPickerSingleProps | DayPickerRangeProps

const TestDatePicker: React.FC<DatePickerProps> = ({ selected, mode, ...other }) => { // ... return ( <DayPicker mode={mode} selected={selected} {...other} /> ) }

export default TestDatePicker`

Screenshot 2024-01-24 at 12 18 49 PM

BuhayovA avatar Jan 24 '24 13:01 BuhayovA

This is already being discussed in https://github.com/gpbl/react-day-picker/discussions/1570#discussioncomment-3803763, please keep the discussion in the relative page. Thanks!

gpbl avatar Jan 26 '24 09:01 gpbl