@@ -11,13 +11,13 @@ import { CommonProps, DateChangeCallBack, DateRangeFocus, InputProps } from './t
1111export interface DateRangePickerChildrenProps {
1212 startDateInputProps : InputProps
1313 endDateInputProps : InputProps
14- focus ?: DateRangeFocus
14+ focus ?: DateRangeFocus | null
1515}
1616
1717export interface DateRangePickerProps extends CommonProps {
1818 children : ( props : DateRangePickerChildrenProps ) => React . ReactNode
19- startDate ?: Date
20- endDate ?: Date
19+ startDate ?: Date | null
20+ endDate ?: Date | null
2121 minimumLength ?: number
2222 maximumLength ?: number
2323 onStartDateChange ?: DateChangeCallBack
@@ -31,8 +31,8 @@ const defaultListener = () => {}
3131export function DateRangePicker ( {
3232 children,
3333 locale,
34- startDate,
35- endDate,
34+ startDate = null ,
35+ endDate = null ,
3636 onStartDateChange = defaultListener ,
3737 onEndDateChange = defaultListener ,
3838 format,
@@ -45,15 +45,15 @@ export function DateRangePicker({
4545 weekdayFormat,
4646 touchDragEnabled
4747} : DateRangePickerProps ) : React . JSX . Element {
48- const [ focus , setFocus ] = useState < DateRangeFocus | undefined > ( )
49- const [ month , setMonth ] = useState < Date | undefined > ( ( ) => startDate || endDate || new Date ( ) )
48+ const [ focus , setFocus ] = useState < DateRangeFocus | null > ( null )
49+ const [ month , setMonth ] = useState < Date | null > ( ( ) => startDate || endDate || new Date ( ) )
5050 const isTouch = useDetectTouch ( )
5151
5252 const [ startDateInputRef , endDateInputRef , popoverRef ] = useOutsideClickHandler <
5353 HTMLInputElement ,
5454 HTMLInputElement ,
5555 HTMLDivElement
56- > ( ( ) => setFocus ( undefined ) )
56+ > ( ( ) => setFocus ( null ) )
5757
5858 const startDateInputProps = useDateInput ( {
5959 date : startDate ,
@@ -130,7 +130,7 @@ export function DateRangePicker({
130130 onStartDateChange = { onStartDateChange }
131131 onEndDateChange = { onEndDateChange }
132132 onFocusChange = { setFocus }
133- onMonthChange = { setMonth as ( date : Date | null ) => void }
133+ onMonthChange = { setMonth }
134134 minimumDate = { minimumDate }
135135 maximumDate = { maximumDate }
136136 minimumLength = { minimumLength }
0 commit comments