From bf909c25f3fed9075e3363e16e875910aad63b0c Mon Sep 17 00:00:00 2001 From: Rodolfo Gobbi De Angeli Date: Sun, 19 Jan 2025 17:12:44 +0100 Subject: [PATCH] docs: fix custom components docs (#2668) --- examples/CustomDayButton.tsx | 50 +++++++++++-------- website/docs/guides/custom-components.mdx | 58 +++++++++++++---------- 2 files changed, 65 insertions(+), 43 deletions(-) diff --git a/examples/CustomDayButton.tsx b/examples/CustomDayButton.tsx index 3ee83439f..6c2af5857 100644 --- a/examples/CustomDayButton.tsx +++ b/examples/CustomDayButton.tsx @@ -1,27 +1,39 @@ import React from "react"; -import { DayPicker } from "react-day-picker"; +import { DayButtonProps, DayPicker } from "react-day-picker"; + +const SelectedDateContext = React.createContext<{ + selected?: Date; + setSelected?: React.Dispatch>; +}>({}); + +function DayButton(props: DayButtonProps) { + const { day, modifiers, ...buttonProps } = props; + + const { setSelected } = React.use(SelectedDateContext); + return ( +