I am gonna implement LIKE and DISLIKE function in my FlatList.
And in here I want to use lottie animation instead of vector-icons.(heart animation)
Then I am not sure how to animate separate animation in FlatList. (Animation by using vector-icon is working well.) All data of separate item comes from backend.(e.g: isLike: 1 or 0)
How to implement it? Following is my code.
const animation = useRef(null);
const likeRestaurant = (item) => {
// how to ... ?
}
const renderRestaurant = ({ item }) => (
<View style={styles.resItem}>
<TouchableOpacity onPress={() => likeRestaurant(item)}>
{/* <MaterialCommunityIcons
color="red" size={20}
name={item.isLike === 1 ? "heart" : "heart-outline"} // This is working well.
/> */}
<LottieView
ref={animation}
style={styles.heartLottie}
source={require("../assets/like.json")}
autoPlay={false}
loop={false}
/>
</TouchableOpacity>
</View>
)
// render
<FlatList
data={restaurantList ? restaurantList : []}
numColumns={2}
keyExtractor={(item, index) => index.toString()}
renderItem={renderRestaurant}
/>