UNPKG

react-day-picker

Version:

Customizable Date Picker for React

18 lines (15 loc) 485 B
import { useContext } from 'react'; import { DayPickerContext, DayPickerContextValue } from './DayPickerContext'; /** * Hook to access the [[DayPickerContext]]. * * To use this hook make sure to wrap the components with a one * [[DayPickerProvider]]. */ export function useDayPicker(): DayPickerContextValue { const context = useContext(DayPickerContext); if (!context) { throw new Error(`useDayPicker must be used within a DayPickerProvider.`); } return context; }