0

I have a query that fetches all data, and also have a mutation that handles delete an item

const {
  isFetching: isFetchingProducts,
  data: productsData,
  refetch
} = useGetProductsQuery("");
const [
  deleteProduct,
  { isSuccess: productDeleted, error: deleteProductFailed }
] = useDeleteProductMutation();

I'm trying to make productDeleted false when isFetchingProducts is true, we could achieve that in old redux by for example

case(GET_PRODUCTS) 
   isFetching: true, 
   productDeleted: false

How to do that in the RTK query? thanks

Ryan Le
  • 7,708
  • 1
  • 13
  • 23

1 Answers1

0

Those two exist completely independently from each other, so there is no real way of doing that.

We will be adding a .reset functionality at some point in the future (github issue here), but currently you will just have to track something like that in a local component state variable.

phry
  • 35,762
  • 5
  • 67
  • 81