Code for Animated Flatlist
const scrollY = useRef(new Animated.Value(0)).current;
const keyExtractorItem = useCallback((item) => item.id.toString(), []);
const anEvent = Animated.event(
[
{
nativeEvent: {
contentOffset: {
y: scrollY,
},
},
},
{ useNativeDriver: true }
],
);
<AnimatedFlashList
onScroll={anEvent}
contentContainerStyle={{ paddingTop: StatusBar.currentHeight || 42 }}
data={DATA}
keyExtractor={keyExtractorItem}
renderItem={renderItem}
estimatedItemSize={20}
/>
Error Occured While Scrolling
Event has less arguments than mapping
Warning Shown
ANIMATED.EVENT NOW REQUIRES A SECOND ARGUMENT FOR OPTIONS
Error Solved
const anEvent = Animated.event(
[
{
nativeEvent: {
contentOffset: {
y: scrollY,
},
},
},
],
{ useNativeDriver: true }
);
UseNativeDriver should be below the array.