react-native-full-calendars
Version:
React Native Full Calendar (RNFC) is an intuitive and powerful calendar component library designed for React Native.
35 lines (34 loc) • 922 B
JavaScript
;
import { useCallback } from 'react';
import { differenceInCalendarMonths } from 'date-fns';
export function useCalendarController(props) {
const {
swiperRef,
initialDate
} = props;
const goToDatePage = (date, options) => {
const animated = options?.animated ?? false;
const page = differenceInCalendarMonths(date, initialDate);
swiperRef.current?.setPage(page, {
animated
});
};
const goToNextPage = useCallback(async (options = {}) => {
const animated = options?.animated ?? true;
swiperRef.current?.nextPage({
animated
});
}, [swiperRef]);
const goToPrevPage = useCallback(async (options = {}) => {
const animated = options?.animated ?? true;
swiperRef.current?.prevPage({
animated
});
}, [swiperRef]);
return {
goToDatePage,
goToNextPage,
goToPrevPage
};
}
//# sourceMappingURL=useCalendarController.js.map