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 with flatlist numColumns > 1

See original GitHub issue

Description

Hey i was trying to make layout animation with flatlist it works just fine with numColumns 1 but if i try 2 or more than 1 it doesn’t work anymore when i delete item or add new one the whole item re render which not happening when numColumns set to 1

Expected behavior

when add new item or delete it should animate the other item to re order them not re render the whole list again!.

Actual behavior & steps to reproduce

https://user-images.githubusercontent.com/70872870/148182776-944a7e96-8179-4893-8c99-9189288c6e84.mov

https://user-images.githubusercontent.com/70872870/148182794-d7820ebb-8029-487e-9b51-2b71aeabca29.mov

Snack or minimal code example

Flatlist -:

<Animated.FlatList
          key={columns ? "oneRow" : "twoRow"}
          data={Tasks.data}
          numColumns={columns ? 1 : 2}
          showsVerticalScrollIndicator={false}
          itemLayoutAnimation={Layout}
          style={styles.Wrapper}
          renderItem={({ item, index }) => (
            <List
              key={index}
              index={index}
              item={item}
              DeleteHanlder={DeleteHanlder}
            />
          )}
        />

item itself -:

<Animated.View
        entering={FadeInDown.springify().delay(index * 150)}
        exiting={FadeOutUp.springify()}
        .....

Package versions

  • React Native: 0.64.3
  • React Native Reanimated: ~2.3.1

Affected platforms

  • [✅] iOS

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:7

github_iconTop GitHub Comments

2reactions
Majiedocommented, May 7, 2022

i found work around if anyone interesting i’ll show you guys when i’m back home…

0reactions
Majiedocommented, May 7, 2022

anyway the solution was to replace flatlist with scrolllist and make the width of the content half of the screen so it will be two columns and add the layout prop to animated view for the item.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to animate a single item from Flatlist array in React Native
What you need to do is isolated the item and animation state in another component then each item will have your own animation...
Read more >
FlatList - React Native
FlatList. A performant interface for rendering basic, flat lists, supporting the most handy features: Fully cross-platform.
Read more >
Usage | FlashList
If you are familiar with FlatList, you already know how to use ... when you have grid layouts (numColumns > 1) and you...
Read more >
Multi-width Flatlist leaving empty spaces when numColumns ...
I define what width the component should be using a prop called 'layout' and it can be either 1 for full width, or...
Read more >
Example of GridView using FlatList in React Native
1 To Import FlatList in Code · 2 Render Using · 3 To Make a React Native App · 4 Code. 4.1 App.js...
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