MCPcopy Create free account
hub / github.com/bridge-codes/bridge / useBridgeMutation

Function useBridgeMutation

packages/bridge-react-query/source/index.ts:41–55  ·  view source on GitHub ↗
(
  mutationFn: MutationFunction<
    { data: TData; error: undefined } | { data: undefined; error: TError },
    TVariables
  >,
  options?: Omit<
    UseMutationOptions<Exclude<TData, undefined>, Exclude<TError, undefined>, TVariables, TContext>,
    'mutationFn'
  >,
)

Source from the content-addressed store, hash-verified

39 );
40
41const useBridgeMutation = <TData, TError, TVariables = void, TContext = any>(
42 mutationFn: MutationFunction<
43 { data: TData; error: undefined } | { data: undefined; error: TError },
44 TVariables
45 >,
46 options?: Omit<
47 UseMutationOptions<Exclude<TData, undefined>, Exclude<TError, undefined>, TVariables, TContext>,
48 'mutationFn'
49 >,
50) =>
51 useMutation(async (input: TVariables) => {
52 const { data, error } = await mutationFn(input);
53 if (error) throw error;
54 return data as Exclude<TData, undefined>;
55 }, options);
56
57export * from '@tanstack/react-query';
58export { useBridgeQuery, useBridgeMutation };

Callers 1

index.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected