reactjs - 在循环中调用 useMutation,如 react-query 中的 useQueries
问题描述
即使我也想拥有相同的功能,我需要在 Side a 循环中调用 useMutation,在该循环中准备数据并作为有效负载发送
aDeleteVariantData.forEach((oDeleteItem, nIndex) => {
oDeleteVariants.mutate(oDeleteItem);
// We are able to delete with axios directly but not using the mutate functionality.
// how should achive this.
// delete(`/varient varientId= ${(oDeleteItem.id)}`)
//For Each delete we have different url parameters which is not possible with the mutate
// Is there anything like useQuries for useMutate
});
解决方案
您可以通过 mutate 函数触发许多删除请求Promise.all
。那时它仍然只是一个突变。
推荐阅读
- sas - 识别重叠用药
- angular - 添加路由后清空 Angular 站点
- dataframe - 如何将 spark Dataframe 写入 clickhouse
- c++ - C++ 语言中的构造函数
- python - GeoPandas 多图中的共享图例
- c++ - 使用MinGW将Linux下的wxWidgets交叉编译到WINdows
- python - n 维井字棋对角线检查器(预测谁将一举获胜)
- php - 创建条件短代码回显 - WP/Woocommerce
- python-3.x - 无法在 Jetson Nano 上安装 scikit_learn
- python - 使用每个类的 ImageDataGenerator 仅使用 N 个图像