-
I'm trying to animate items inside my const AnimatedFlatList = Animated.createAnimatedComponent(FlatList)
const animatedTabStyle = useAnimatedStyle(() => {
const opacity = interpolate(
scrollValue.value,
[0, 65],
[1, 0],
Extrapolate.CLAMP
)
return {
opacity
}
})
}
const handleScroll = useAnimatedScrollHandler({
onScroll: ({ contentOffset }) => {
scrollValue.value = contentOffset.y
}
})
...
<AnimatedFlatList
onScroll={handleScroll}
data={tabs}
renderItem={({ item, index }) => {
return (
<Animated.View style={animatedTabStyle}>
<Text>Hello Reanimated</Text>
</Animated.View>
)
}}
/> |
Beta Was this translation helpful? Give feedback.
Answered by
dannyhw
Nov 10, 2021
Replies: 1 comment 1 reply
-
I believe that each render item needs an animated style, so something like this should work. Although it will complain if you have the eslint plugin that you shouldn't use hooks like this. If you make the renderitem a component and the style local to the component you can get around that.
excuse the bad formatting/indenting 😅 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
akinncar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe that each render item needs an animated style, so something like this should work. Although it will complain if you have the eslint plugin that you shouldn't use hooks like this. If you make the renderitem a component and the style local to the component you can get around that.