File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -114,14 +114,18 @@ export function useAutoScroll<T>() {
114114 isAutoScrollInProgress . current . native . setValue ( 1 ) ;
115115 isAutoScrollInProgress . current . js = true ;
116116
117- const flatlistNode : FlatList < T > | null =
118- "scrollToOffset" in flatlistRef
119- ? flatlistRef
120- : "getNode" in flatlistRef
121- ? //@ts -ignore backwards compat
122- flatlistRef . getNode ( )
123- : null ;
124- flatlistNode ?. scrollToOffset ?.( { offset } ) ;
117+ function getFlatListNode ( ) : FlatList < T > | null {
118+ if ( ! flatlistRef . current ) return null ;
119+ if ( "scrollToOffset" in flatlistRef . current )
120+ return flatlistRef . current as FlatList < T > ;
121+ //@ts -ignore backwards compat
122+ if ( "getNode" in flatlistRef . current ) return flatlistRef . getNode ( ) ;
123+ return null ;
124+ }
125+
126+ const flatListNode = getFlatListNode ( ) ;
127+
128+ flatListNode ?. scrollToOffset ?.( { offset } ) ;
125129 } ) ;
126130
127131 const getScrollTargetOffset = (
You can’t perform that action at this time.
0 commit comments