Component FlatList trong React Native là gì?
Component FlatList trong React Native là gì?
FlatList hiển thị danh sách dài hiệu quả nhờ ảo hoá (virtualization): chỉ render các item gần khung nhìn, giải phóng phần còn lại.
<FlatList
data={users}
keyExtractor={(u) => u.id}
renderItem={({ item }) => <UserRow user={item} />}
ItemSeparatorComponent={() => <View style={{ height: 1, backgroundColor: "#eee" }} />}
ListHeaderComponent={<Header />}
ListEmptyComponent={<Empty />}
onEndReached={loadMore}
onEndReachedThreshold={0.5}
refreshing={refreshing}
onRefresh={onRefresh}
getItemLayout={(_, i) => ({ length: 64, offset: 64 * i, index: i })} // nếu chiều cao cố định
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.