UNPKG

545 BTypeScriptView Raw
1import React from "react";
2
3import { subDays } from "date-fns";
4import { DayPicker, SelectSingleEventHandler } from "react-day-picker";
5
6export function ModifiersSelected() {
7 const yesterday = subDays(new Date(), 1);
8 const handleSelect: SelectSingleEventHandler = (value, date, modifiers) => {
9 if (modifiers.selected) {
10 alert("You clicked a selected day.");
11 }
12 if (modifiers.today) {
13 alert("You clicked today");
14 }
15 };
16 return (
17 <DayPicker mode="single" selected={yesterday} onSelect={handleSelect} />
18 );
19}