lundi 24 mai 2021

how to get id of particular item in list of items in flatlist when user check the checkbox of item

I have wishlist screen, User put products into wishlist screen, but how we get id of item when user check the particular product. because remove item and add to cart button is on header. so how we get id,so checked item we will detete the item and add to cart item.

                     <FlatList 
                        data={wishlist}
                        keyExtractor={(item, index) => {
                            return `${item[0].itemWishlistId}product`;
                        }}

                        // keyExtractor={item => item[0].itemWishlistId}
                        renderItem={itemData =>    
                            <View style={styles.mainContainer}>
                                <View style=>
                                    <View style={styles.checkBoxContainer}>
                                        <Checkbox 
                                            color="#192341"
                                            uncheckedColor="#A9A9A9"
                                            status={checked ? 'checked' : 'unchecked'}
                                            onPress={() => handleClick(itemData.item[0].itemWishlistId)}
                                        />
                                    </View>  
                        
                                    <View style=>
                                            <Text style=>{itemData.item[0].itemWishlistTitle}</Text>
                                    </View>
                                    
                                    <View style=>
                                        <TouchableOpacity 
                                            onPress={() => {
                                                onTapRemoveFromWishlist(wishlistItems)
                                            }}>         
                                            <SvgXml xml={xml.rightArrow}  marginTop={26} width={18} height={18}/> 
                                        </TouchableOpacity>
                                    </View>
                            </View> 
                                <Image source={require('../assets/images/VectorLine.png')} style=/>
                            </View>
                         }
                    />

Here is handleClick funtion of checkbox

let productId;
const handleClick = (itemId) => {
    // setChecked(!checked)
    productId = itemId;
};

this is flatlist of items. and this sample image. How it be done??

deenter image description here




Aucun commentaire:

Enregistrer un commentaire