[2.3.0-alpha.3] Layout animation does not work inside `FlatList`
See original GitHub issueDescription
Participant list example when using FlatList
:
Participant list example when using ScrollView
:
Expected behavior
When using FlatList
, layout={Layout.springify()}
causes the list elements to slide into their new positions with a spring animation.
Actual behavior & steps to reproduce
When using FlatList
, layout={Layout.springify()}
has no effect.
Snack or minimal code example
I’ve modified this file in the example app:
@@ -3,9 +3,10 @@ import {
Button,
View,
Text,
- ScrollView,
TextInput,
StyleSheet,
+ FlatList,
+ ListRenderItem,
} from 'react-native';
import Animated, {
Layout,
@@ -90,17 +91,20 @@ export default function AnimatedListExample(): React.ReactElement {
);
};
+ const renderItem: ListRenderItem<EventParticipant> = ({item}) => (
+ <Participant
+ name={item.name}
+ onRemove={() => removeParticipant(item.id)}
+ />
+ );
+
return (
<View style={[styles.listView]}>
- <ScrollView style={[{ width: '100%' }]}>
- {participantList.map((participant) => (
- <Participant
- key={participant.id}
- name={participant.name}
- onRemove={() => removeParticipant(participant.id)}
- />
- ))}
- </ScrollView>
+ <FlatList
+ style={[{ width: '100%' }]}
+ data={participantList}
+ renderItem={renderItem}
+ keyExtractor={({id}) => id} />
<View style={[styles.bottomRow]}>
<View style={[styles.textInput]}>
Package versions
- React Native: 0.65.1
- React Native Reanimated: 2.3.0-alpha.3
- NodeJS: 16.6.1
- Xcode: 12.5.1
- Java & Gradle: -
Affected platforms
- Android
- iOS
- Web
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
LayoutAnimation not working when reordering flatlist items
I got the sortOrder of every item as the item´s key. KeyExtractor of the Flatlist is also using the sortOrder of the items....
Read more >react native flatlist infinite loop - You.com | The AI Search ...
scrollToIndex({index: this.state.currentStepIndex - 1, animated: true});. If I run with the Remote Debugger active, everything works fine. If I don't use ...
Read more >react-native-reanimated: Versions - Openbase
2.3.0-alpha.3 ... We decided to redesign the architecture of Layout Animations to make them even more efficient and less buggy. That is why...
Read more >Layout Transitions | React Native Reanimated
There are plenty of ways in which you can animated layout changes however in contrast to entering and exiting animations they are not...
Read more >Animated FlatList in React Native (Reanimated) - YouTube
What's up mobile devs? Today we're going to build from scratch a super powerful and simple animation over the React Native FlatList ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We are considering to create own simple modification of FlatList, but unfortunately, I don’t know when yet.
Hi, @piaskowyk! Are you planning to create your own modification of SectionList component in the nearest future? It has a similar issue as FlatList. Will be really helpful to me 🙂
Thanks!