Layout Animation with flatlist numColumns > 1
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 validator
The issue is valid!
Did you solve this?
Did you solve this?
no, i even made repo for this issue if anyone want to clone and test it out here
Bruh why is this documentation so bad
Bruh why is this documentation so bad
sure the documentation not that great but still it's not that bad , but i have been with this issue for like 3 months and still didn't solve it....tried everything but still...i think i missing something so i'm waiting for any better developer to help me 😞
i found work around if anyone interesting i'll show you guys when i'm back home...
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.
Thank you for submitting this issue! Unfortunately we are not planning to support this feature (multiple columns flatList) and I'm glad you've found other solution.
The bug explanation: When numColumns is grater than 1 keyExtractor is substituted under the hood, so your keys don't match. It is difficult to fix, since all elements in a single row have the very same key, so you can't differ between two views in a single row.
"I'm glad you've found other solution." - replacing flatlist with scrollview is never a good solution for optimizational reasons... it will eventually bite you for that reason.
"I'm glad you've found other solution." - replacing flatlist with scrollview is never a good solution for optimizational reasons... it will eventually bite you for that reason.
not really, it depends on the quantity of items within the list.
"I'm glad you've found other solution." - replacing flatlist with scrollview is never a good solution for optimizational reasons... it will eventually bite you for that reason.
not really, it depends on the quantity of items within the list.
Absolutely, but im asuming people use flatlist for starters because of the reason it can/will contain lots of items. If not... im stunned.
I absolutely can't switch to a scrollview for performance reasons! and at the moment the entry and exit animations are broken. Any new solution?
I absolutely can't switch to a scrollview for performance reasons! and at the moment the entry and exit animations are broken. Any new solution?
Unfortunately, this is the only workaround I have found to switch the ScrollView. I fully understand that the FlatList is more optimized for handling larger lists
I used a library called moti.fyi It works like magic :)
If the list is big, then implement a way to render animation on the first few list items that are on the screen and leave the rest because they are not on the screen anyway :)