From 5557400e724dd3ff0ef98fd75adcf667171d01b9 Mon Sep 17 00:00:00 2001 From: builder_247 <14019974+builder-247@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:12:12 +0300 Subject: [PATCH] fix --- elements/timetable/Timetable.tsx | 8 ++++---- hooks/useNavigationPanel.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/elements/timetable/Timetable.tsx b/elements/timetable/Timetable.tsx index e78e5fc..97a0927 100644 --- a/elements/timetable/Timetable.tsx +++ b/elements/timetable/Timetable.tsx @@ -15,9 +15,9 @@ const Timetable = () => { const [eventDayIndex, setEventDayIndex] = useState(0); const callback = useCallback((position: number) => { - console.log('Hey', `You are on ${position + 1} page`); + setEventDayIndex(position); }, []); - const { ref, nextPage, previousPage, ...navigationPanel } = useNavigationPanel(callback); + const { ref, nextPage, previousPage, onPageSelected } = useNavigationPanel(callback); useEffect(() => { getEvents().then((eventRes) => { @@ -44,7 +44,7 @@ const Timetable = () => { const index = eventsGroupedByDay.findIndex( (events) => events[events.length - 1].end.getTime() > new Date().getTime() ); // If last event of the day has ended, it's not the current day - // setEventDayIndex(index === -1 ? eventsGroupedByDay.length - 1 : index); + setEventDayIndex(index === -1 ? eventsGroupedByDay.length - 1 : index); }); }, []); @@ -71,7 +71,7 @@ const Timetable = () => { ref={ref} useNext={false} initialPage={eventDayIndex} - {...navigationPanel} + onPageSelected={onPageSelected} layoutDirection='ltr' orientation='horizontal' style={{ flex: 1 }} diff --git a/hooks/useNavigationPanel.ts b/hooks/useNavigationPanel.ts index e6a9044..55610c0 100644 --- a/hooks/useNavigationPanel.ts +++ b/hooks/useNavigationPanel.ts @@ -31,7 +31,7 @@ export function useNavigationPanel(onPageSelectedCallback: (position: number) => setActivePage(position); onPageSelectedCallback(position); }, - useNativeDriver: true, + useNativeDriver: false, } ), []