在react-query中像useQueries一样在循环中调用useMutation

时间:2021-01-28 14:10:35

标签: reactjs react-query

即使我也想拥有相同的功能,我需要在 Side 中调用 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

});

1 个答案:

答案 0 :(得分:0)

您可以通过 Promise.all 使您的 mutate 函数触发许多删除请求。那么它仍然只是一个突变。