mirror of
https://github.com/urosran/cally.git
synced 2025-07-10 07:07:16 +00:00
27 lines
765 B
TypeScript
27 lines
765 B
TypeScript
import React from 'react';
|
|
import {useAtomValue} from 'jotai';
|
|
import {selectedDateAtom} from '@/components/pages/calendar/atoms';
|
|
import {FlashList} from "@shopify/flash-list";
|
|
import {useDidUpdate} from "react-native-ui-lib/src/hooks";
|
|
|
|
interface CalendarControllerProps {
|
|
scrollViewRef: React.RefObject<FlashList<any>>;
|
|
centerMonthIndex: number;
|
|
}
|
|
|
|
export const CalendarController: React.FC<CalendarControllerProps> = (
|
|
{
|
|
scrollViewRef,
|
|
centerMonthIndex
|
|
}) => {
|
|
const selectedDate = useAtomValue(selectedDateAtom);
|
|
|
|
useDidUpdate(() => {
|
|
scrollViewRef.current?.scrollToIndex({
|
|
index: centerMonthIndex,
|
|
animated: false
|
|
})
|
|
}, [selectedDate, centerMonthIndex]);
|
|
|
|
return null;
|
|
}; |