在本机循环中使用 onPress 获取在 const 中设置的产品 ID

问题描述

我想在 pid 使用 onPress 中添加 key={item.id} 值,并且她的数据在 react native 中进入数据库使用循环

const addToWishlist = () => {
     const [pid,setPid] = useState('');
}
return (
  <>
   {ProductData.map((item,index) => {
     return (
       <View key={index} style={styles.prod}>
         <TouchableOpacity onPress={addToWishlist} key={item.id}>
           <Feather name="heart" color={heartColor} style={{fontSize:16}}/>
         </TouchableOpacity>
       </View>
     )
   })}
  </>
)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)