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

Function Component

packages/react-query/src/__tests__/useMutation.test.tsx:864–895  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

862 }
863
864 function Component() {
865 const mutation = useMutation({
866 mutationFn: async (_text: string) => {
867 count++
868 await sleep(10)
869 return count
870 },
871 mutationKey,
872 gcTime: 0,
873 onSuccess,
874 onSettled,
875 })
876
877 return (
878 <div>
879 <button
880 onClick={() =>
881 mutation.mutate('todo', {
882 onSuccess: onSuccessMutate,
883 onSettled: onSettledMutate,
884 })
885 }
886 >
887 mutate
888 </button>
889 <div>
890 data: {mutation.data ?? 'null'}, status: {mutation.status},
891 isPaused: {String(mutation.isPaused)}
892 </div>
893 </div>
894 )
895 }
896
897 const rendered = renderWithClient(queryClient, <Page />)
898

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…