Skip to content

Commit 2081219

Browse files
committed
Changed types of value and onChange to be the same.
1 parent 589ea9d commit 2081219

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/components/Datepicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import DatepickerContext from "../contexts/DatepickerContext";
1414
interface Props {
1515
primaryColor?: string,
1616
value: {
17-
startDate: string | Date,
18-
endDate: string | Date
17+
startDate: string | Date | null,
18+
endDate: string | Date | null
1919
} | null,
20-
onChange: (value: {startDate: string | Date, endDate: string | Date} | null) => void,
20+
onChange: (value: {startDate: string | Date | null, endDate: string | Date | null} | null) => void,
2121
useRange?: boolean,
2222
showFooter?: boolean,
2323
showShortcuts?: boolean,

src/contexts/DatepickerContext.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import React, {createContext} from "react";
22
import dayjs from "dayjs";
33
import {Configs, Period} from "../types";
44

5+
type DateRange = {
6+
startDate: string | Date | null,
7+
endDate: string | Date | null,
8+
} | null;
9+
510
interface DatepickerStore {
611
asSingle?: boolean,
712
primaryColor: string,
@@ -15,15 +20,12 @@ interface DatepickerStore {
1520
inputText: string,
1621
changeInputText: (text: string) => void,
1722
updateFirstDate: (date: dayjs.Dayjs) => void,
18-
changeDatepickerValue: (value: {startDate: string | Date, endDate: string | Date} | null) => void,
23+
changeDatepickerValue: (value: DateRange) => void,
1924
showFooter?: boolean,
2025
placeholder?: string | null,
2126
separator?: string,
2227
i18n: string,
23-
value: {
24-
startDate: Date | string,
25-
endDate: Date | string,
26-
} | null
28+
value: DateRange
2729
}
2830

2931
const DatepickerContext = createContext<DatepickerStore>({

0 commit comments

Comments
 (0)