From 6b0a2b31fbde89cd0197733099f4766932348258 Mon Sep 17 00:00:00 2001 From: M-i-k-e-l Date: Wed, 4 Sep 2024 10:08:31 +0300 Subject: [PATCH] TabController - fix indicator when using old reanimated (ignore TS) --- src/components/tabController/useScrollToItem.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/tabController/useScrollToItem.ts b/src/components/tabController/useScrollToItem.ts index ff06062f0e..ffbd7ab99c 100644 --- a/src/components/tabController/useScrollToItem.ts +++ b/src/components/tabController/useScrollToItem.ts @@ -100,8 +100,8 @@ const useScrollToItem = (props: ScrollToItemPr innerSpacing = 0 } = props; const itemsWidths = useRef<(number | null)[]>(_.times(itemsCount, () => null)); - const itemsWidthsAnimated = useSharedValue(_.times(itemsCount, () => 0)); - const itemsOffsetsAnimated = useSharedValue(_.times(itemsCount, () => 0)); + const itemsWidthsAnimated = useSharedValue(_.times(itemsCount, () => 0)); + const itemsOffsetsAnimated = useSharedValue(_.times(itemsCount, () => 0)); const currentIndex = useRef(selectedIndex || 0); const [offsets, setOffsets] = useState({CENTER: [], LEFT: [], RIGHT: []}); const {scrollViewRef, scrollTo, onContentSizeChange, onLayout} = useScrollTo({scrollViewRef: propsScrollViewRef}); @@ -148,12 +148,10 @@ const useScrollToItem = (props: ScrollToItemPr setOffsets({CENTER: centeredOffsets, LEFT: leftOffsets, RIGHT: rightOffsets}); // default for DYNAMIC is CENTER // Update shared values + // @ts-expect-error pretty sure this is a bug in reanimated since itemsWidthsAnimated is defined as SharedValue itemsWidthsAnimated.modify((value) => { 'worklet'; - value.forEach((_, index) => { - value[index] = widths[index]; - }); - return value; + return value.map((_, index) => widths[index]); }); itemsOffsetsAnimated.modify((value) => {