Skip to content

How to animate items inside a list? #2619

Answered by dannyhw
akinncar asked this question in Q&A
Discussion options

You must be logged in to vote

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.

<AnimatedFlatList
  onScroll={handleScroll}
  data={tabs}
  renderItem={({ item, index }) => {

   const animatedTabStyle = useAnimatedStyle(() => {
    const opacity = interpolate(
      scrollValue.value,
      [0, 65],
      [1, 0],
      Extrapolate.CLAMP
    )

      return {
        opacity
      }
    })
  }
    return (
      <Animated.View style={animatedTabStyle}>
        <Text>Hello Reanimated…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@akinncar
Comment options

Answer selected by akinncar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants