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

What is the event type for FlatList's onScroll in react native?

$
0
0

Typescript is complaining Parameter 'event' implicitly has an 'any' type. for the event in the onScroll function.

const onScroll = (event) => {  console.log("width: ", event.nativeEvent.layoutMeasurement.width);};<FlatList    data={data}    renderItem={renderItem}    onScroll={onScroll}/>

Then I traced onScroll prop on the FlatList, found

/** * Fires at most once per frame during scrolling. * The frequency of the events can be contolled using the scrollEventThrottle prop. */onScroll?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;

Then I updated the onScroll to the following, event type complaining is gone, but it's now complaining "Property 'nativeEvent' does not exist on type 'NativeSyntheticEvent'" for event.nativeEvent

const onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {  console.log("width: ", event.nativeEvent.layoutMeasurement.width);};

What is the event type for the onScroll's event parameter?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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