Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

Typescript React Native Property 'scrollToIndex' does not exist on type 'FlatList'

$
0
0

I have a component that scrolls a React Native FlatList:

<BottomCarousel   ...   onSnapToItem={(index) => {      myList.current?.scrollToIndex({ animated: false, index });   }}/>

myList is a FlatList which is referenced with useRef:

const myList = useRef<FlatList<SomeList>>(null);

And I define the type of the list with:

type SomeList = {  id: string;  name: string;  ...

Nothing special here. It all works, but I get a TypeScript warning/error:

Property 'scrollToIndex' does not exist on type 'FlatList<SomeList>'.

Any ideas why? What am I doing wrong here?


Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>