question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Layout Animation doesn't work on Android with FlatList

See original GitHub issue

Description

There is two different behavior between iOS and Android, in fact on iOS this code runs without any problem but on Android none of theses animations works.

Expected behavior

The items should enter and exit smoothly for both platforms.

Actual behavior & steps to reproduce

iOS => The items enter and exit smoothly Android => The items enter and exit without animations

To reproduce, just runs this code with your own renderItem.

Snack or minimal code example

import React from 'react'
import { FlatList, FlatListProps } from 'react-native'
import Animated, { FadeInUp, FadeOut } from 'react-native-reanimated'

interface Props extends FlatListProps<any> {

}

const AnimatedFlatList = Animated.createAnimatedComponent(FlatList)

const createCellRenderer = () => {
    const cellRenderer: React.FC = (props) => {
        return (
            <Animated.View
                entering={FadeInUp.duration(250)}
                exiting={FadeOut.duration(250)}
            >
                {props.children}
            </Animated.View>
        )
    }

    return cellRenderer
}

export const AnimatedList = (props: Props) => {
    const CellRenderer = React.useMemo(
        () => createCellRenderer(),
        [],
    )

    return (
        <AnimatedFlatList
            {...props}
            CellRendererComponent={CellRenderer}
        />
    )
}

Package versions

  • React Native: 0.64.3
  • React Native Reanimated: 2.3.1
  • NodeJS: 16.13.0

Affected platforms

  • Android
  • iOS
  • Web

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
adscudcommented, Feb 1, 2022

I come to the news. I tested your implementation which didn’t change much, I went back to the basic Flat List without overloading the cellRenderer, it works for the entering animation on both platforms, only the exiting on Android doesn’t works.

It’s an improvement I have an animation for the entering on Android. 😃

3reactions
adscudcommented, Mar 6, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Layout animation doesn't work with FlatList #2737 - GitHub
When I try to use FlatList instead of ScrollView, as shown in the tutorial below, the Layout.springify() doesn't work.
Read more >
react native - flat list android animation doesn't work as expected
On IOS It's work fine but on ANDROID not. the animation contains fade in and transform: translateX animation. If there another way to...
Read more >
The magic of Layout Animations in Reanimated (React Native)
In this tutorial we'll learn how to handle the new feature of Reanimated 2: Layout Animations. In order to do it we're going...
Read more >
Usage | FlashList
FlashList , as FlatList , uses ScrollView under the hood. You can take a look into the React Native documentation for ScrollView to...
Read more >
Animated - React Native
Don't modify the animated value directly. ... Working with animations​ ... The interpolate() function allows input ranges to map to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found