@@ -100,8 +100,8 @@ const useScrollToItem = <T extends ScrollToSupportedViews>(props: ScrollToItemPr
100100 innerSpacing = 0
101101 } = props ;
102102 const itemsWidths = useRef < ( number | null ) [ ] > ( _ . times ( itemsCount , ( ) => null ) ) ;
103- const itemsWidthsAnimated = useSharedValue ( _ . times ( itemsCount , ( ) => 0 ) ) ;
104- const itemsOffsetsAnimated = useSharedValue ( _ . times ( itemsCount , ( ) => 0 ) ) ;
103+ const itemsWidthsAnimated = useSharedValue < number [ ] > ( _ . times ( itemsCount , ( ) => 0 ) ) ;
104+ const itemsOffsetsAnimated = useSharedValue < number [ ] > ( _ . times ( itemsCount , ( ) => 0 ) ) ;
105105 const currentIndex = useRef < number > ( selectedIndex || 0 ) ;
106106 const [ offsets , setOffsets ] = useState < Offsets > ( { CENTER : [ ] , LEFT : [ ] , RIGHT : [ ] } ) ;
107107 const { scrollViewRef, scrollTo, onContentSizeChange, onLayout} = useScrollTo < T > ( { scrollViewRef : propsScrollViewRef } ) ;
@@ -148,12 +148,10 @@ const useScrollToItem = <T extends ScrollToSupportedViews>(props: ScrollToItemPr
148148 setOffsets ( { CENTER : centeredOffsets , LEFT : leftOffsets , RIGHT : rightOffsets } ) ; // default for DYNAMIC is CENTER
149149
150150 // Update shared values
151+ // @ts -expect-error pretty sure this is a bug in reanimated since itemsWidthsAnimated is defined as SharedValue<number[]>
151152 itemsWidthsAnimated . modify ( ( value ) => {
152153 'worklet' ;
153- value . forEach ( ( _ , index ) => {
154- value [ index ] = widths [ index ] ;
155- } ) ;
156- return value ;
154+ return value . map ( ( _ , index ) => widths [ index ] ) ;
157155 } ) ;
158156
159157 itemsOffsetsAnimated . modify ( ( value ) => {
0 commit comments