阅读时间:1 分钟
0 字

useCustomMutation

useCustomMutation 用于自定义提交请求。

使用方法

ts
import { useCustomMutation } from '@duxweb/dvha-core'

const { mutate, isLoading } = useCustomMutation({
  path: 'users/import',
  method: 'POST',
})

mutate({ payload: [{ name: '张三' }] })

参数说明

useCustomMutation 继承 IDataProviderCustomOptions,并支持:

参数类型说明
providerNamestring数据提供者名称,默认 default
optionsUseMutationOptionsTanStack Query 选项
onSuccess(data: IDataProviderResponse) => void成功回调
onError(error: IDataProviderError) => void错误回调

返回值

字段类型说明
mutate(data: IDataProviderCustomOptions) => void触发提交
isLoadingComputedRef<boolean>是否提交中