/
ai_sampletext
/
DiplomWork
Обзор
Документация
Войти
/
ai_sampletext
/
DiplomWork
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
node_modules/react-day-picker/src/contexts/Navigation/useNavigationState.ts
29 строк
853 B
boolyshareyo
Initial commit
08 июн 2026, 16:00
08 июн 2026, 16:00
6216a29
Код
Авторство
О чём код?
import { startOfMonth } from 'date-fns'; import { useDayPicker } from 'contexts/DayPicker'; import { useControlledValue } from 'hooks/useControlledValue'; import { getInitialMonth } from './utils/getInitialMonth'; export type NavigationState = [ /** The month DayPicker is navigating at */ month: Date, /** Go to the specified month. */ goToMonth: (month: Date) => void ]; /** Controls the navigation state. */ export function useNavigationState(): NavigationState { const context = useDayPicker(); const initialMonth = getInitialMonth(context); const [month, setMonth] = useControlledValue(initialMonth, context.month); const goToMonth = (date: Date) => { if (context.disableNavigation) return; const month = startOfMonth(date); setMonth(month); context.onMonthChange?.(month); }; return [month, goToMonth]; }