-
-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some performance issues when combining FlatList, react-native-gesture-handler, and react-native-reanimated #2856
Comments
2024-04-04.15.54.11.mp4Guys,to add to this, this is the desired effect, the sliding is smooth, and tapping on each block will zoom in and out |
Hi @yinminqian,
Right now, you can work around this issue by wrapping your I'll keep you updated on the state of this issue and will try to resolve it as soon as possible. |
Hi @yinminqian. After some more testing and some discussion with the team I'm inclined to believe the issue you're describing is not related to any of our tools or libraries. Of course, please feel free to keep experimenting with this setup as there could be some things I might have missed. As I previously mentioned, you can fix this issue by memoizing your Code used for testing: import { memo } from 'react';
import React from 'react-native';
import {
Text,
SafeAreaView,
StyleSheet,
View,
FlatList as RNFlatList,
} from 'react-native';
import { FlatList as GHFlatList } from 'react-native-gesture-handler';
const ItemTap = ({ index }: { index: number }) => {
console.log('rendering', index);
return (
<View style={styles.staticBox}>
<Text>{index}</Text>
</View>
);
};
const MemoizedItemTap = memo(ItemTap);
const data = new Array(50).fill('1');
export default function FlatListExample() {
return (
<SafeAreaView style={styles.fill}>
<Text style={styles.topHeader}>Raw</Text>
<View style={styles.container}>
<View style={styles.fill}>
<Text style={styles.header}>GH FlatList</Text>
<GHFlatList
data={data}
style={styles.fill}
renderItem={({ index }) => <ItemTap index={index} />}
/>
</View>
<View style={styles.fill}>
<Text style={styles.header}>RN FlatList</Text>
<RNFlatList
data={data}
style={styles.fill}
renderItem={({ index }) => <ItemTap index={index} />}
/>
</View>
</View>
<Text style={styles.topHeader}>Memoized</Text>
<View style={styles.container}>
<View style={styles.fill}>
<Text style={styles.header}>GH FlatList</Text>
<GHFlatList
data={data}
style={styles.fill}
renderItem={({ index }) => <MemoizedItemTap index={index} />}
/>
</View>
<View style={styles.fill}>
<Text style={styles.header}>RN FlatList</Text>
<RNFlatList
data={data}
style={styles.fill}
renderItem={({ index }) => <MemoizedItemTap index={index} />}
/>
</View>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
topHeader: {
fontSize: 24,
fontWeight: 'bold',
textAlign: 'center',
margin: 5,
borderColor: 'red',
borderWidth: StyleSheet.hairlineWidth,
},
header: {
fontSize: 20,
fontWeight: 'bold',
textAlign: 'center',
margin: 5,
},
fill: {
flex: 1,
},
container: {
flex: 1,
flexDirection: 'row',
},
staticBox: {
height: 200,
borderRadius: 10,
borderWidth: 1,
borderColor: 'red',
marginBottom: 20,
marginHorizontal: 20,
alignItems: 'center',
justifyContent: 'center',
},
}); Results of testing: Screen.Recording.2024-07-29.at.14.22.20.mov |
Description
I am going to replicate the apple store animation effect, there is a zoom in and zoom out effect when sliding the interface and clicking to each View, and a long press can keep the zoom out, I wrote a minimal reproduction of the example, but on the real machine and emulator, as long as the animation and flatlist sliding are running at the same time, it is just a sliding lag, is there something that I am doing wrong? What should I do to improve it? My minimal re-code has been written below
2024-04-04.15.40.00.mp4
Steps to reproduce
Snack or a link to a repository
https://github.com/yinminqian/Troubleshooting
Gesture Handler version
2.15.0
React Native version
0.73.6
Platforms
Android, MacOS
JavaScript runtime
Hermes
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
iphone 11 ,xiaomi10
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: