MCPcopy
hub / github.com/TanStack/query / Component

Function Component

packages/solid-query/src/__tests__/useMutation.test.tsx:949–980  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

947 }
948
949 function Component() {
950 const mutation = useMutation(() => ({
951 mutationFn: async (_text: string) => {
952 count++
953 await sleep(10)
954 return count
955 },
956 mutationKey: mutationKey,
957 gcTime: 0,
958 onSuccess,
959 onSettled,
960 }))
961
962 return (
963 <div>
964 <button
965 onClick={() =>
966 mutation.mutate('todo', {
967 onSuccess: onSuccessMutate,
968 onSettled: onSettledMutate,
969 })
970 }
971 >
972 mutate
973 </button>
974 <div>
975 data: {mutation.data ?? 'null'}, status: {mutation.status},
976 isPaused: {String(mutation.isPaused)}
977 </div>
978 </div>
979 )
980 }
981
982 const rendered = render(() => (
983 <QueryClientProvider client={queryClient}>

Callers

nothing calls this directly

Calls 3

sleepFunction · 0.90
useMutationFunction · 0.50
mutateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…