@@ -100,8 +100,8 @@ const useScrollToItem = <T extends ScrollToSupportedViews>(props: ScrollToItemPr
100
100
innerSpacing = 0
101
101
} = props ;
102
102
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 ) ) ;
105
105
const currentIndex = useRef < number > ( selectedIndex || 0 ) ;
106
106
const [ offsets , setOffsets ] = useState < Offsets > ( { CENTER : [ ] , LEFT : [ ] , RIGHT : [ ] } ) ;
107
107
const { scrollViewRef, scrollTo, onContentSizeChange, onLayout} = useScrollTo < T > ( { scrollViewRef : propsScrollViewRef } ) ;
@@ -148,12 +148,10 @@ const useScrollToItem = <T extends ScrollToSupportedViews>(props: ScrollToItemPr
148
148
setOffsets ( { CENTER : centeredOffsets , LEFT : leftOffsets , RIGHT : rightOffsets } ) ; // default for DYNAMIC is CENTER
149
149
150
150
// Update shared values
151
+ // @ts -expect-error pretty sure this is a bug in reanimated since itemsWidthsAnimated is defined as SharedValue<number[]>
151
152
itemsWidthsAnimated . modify ( ( value ) => {
152
153
'worklet' ;
153
- value . forEach ( ( _ , index ) => {
154
- value [ index ] = widths [ index ] ;
155
- } ) ;
156
- return value ;
154
+ return value . map ( ( _ , index ) => widths [ index ] ) ;
157
155
} ) ;
158
156
159
157
itemsOffsetsAnimated . modify ( ( value ) => {
0 commit comments