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, } ), []