23 lines
878 B
JavaScript
23 lines
878 B
JavaScript
import { createContext, useContext } from "react";
|
|
/** @ignore */
|
|
export const dayPickerContext = createContext(undefined);
|
|
/**
|
|
* Provides access to the DayPicker context, which includes properties and
|
|
* methods to interact with the DayPicker component. This hook must be used
|
|
* within a custom component.
|
|
*
|
|
* @template T - Use this type to refine the returned context type with a
|
|
* specific selection mode.
|
|
* @returns The context to work with DayPicker.
|
|
* @throws {Error} If the hook is used outside of a DayPicker provider.
|
|
* @group Hooks
|
|
* @see https://daypicker.dev/guides/custom-components
|
|
*/
|
|
export function useDayPicker() {
|
|
const context = useContext(dayPickerContext);
|
|
if (context === undefined) {
|
|
throw new Error("useDayPicker() must be used within a custom component.");
|
|
}
|
|
return context;
|
|
}
|
|
//# sourceMappingURL=useDayPicker.js.map
|