Reputation: 37
Argument of type 'Date | [Date, Date] | null' is not assignable to parameter of type 'SetStateAction<Date | null>'
const [startDate, setStartDate] = useState<Date | null>(new Date());
return (
<div className="rounded bg-night-sky p-5">
<div className="d-flex align-items-center justify-content-center flex-wrap">
<div className="m-4">
<DatePicker
selected={startDate}
onChange={(date) => setStartDate(date)}
showTimeSelect
timeFormat="HH:mm"
timeIntervals={20}
timeCaption="time"
dateFormat="MMMM d, yyyy h:mm aa"
/>
</div>
</div>
</div>
);
};
Upvotes: 2
Views: 465
Reputation: 593
try this:
const [startDate, setStartDate] = useState<Date | [Date, Date] | null>(new Date());
return (
<div className="rounded bg-night-sky p-5">
<div className="d-flex align-items-center justify-content-center flex-wrap">
<div className="m-4">
<DatePicker
selected={startDate}
onChange={(date) => setStartDate(date)}
showTimeSelect
timeFormat="HH:mm"
timeIntervals={20}
timeCaption="time"
dateFormat="MMMM d, yyyy h:mm aa"
/>
</div>
</div>
</div>
);
};
Upvotes: 3