import { useDayPicker } from 'contexts/DayPicker' ; import { useControlledValue } from 'hooks/useControlledValue' ; import { getInitialMonth } from './utils/getInitialMonth' ; /** Controls the navigation state. */ export function useNavigationState ( ) { const context = useDayPicker ( ) ; const initialMonth = getInitialMonth ( context ) ; const [ month , setMonth ] = useControlledValue ( initialMonth , context . month ) ; const goToMonth = ( date ) => { if ( context . disableNavigation ) return ; setMonth ( date ) ; } ; return [ month , goToMonth ] ; }