MCPcopy Create free account
hub / github.com/TanStack/query / Component

Function Component

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

Source from the content-addressed store, hash-verified

1237 }
1238
1239 function Component() {
1240 const mutation = useMutation(() => ({
1241 mutationFn: async (_text: string) => {
1242 count++
1243 await sleep(10)
1244 return count
1245 },
1246 mutationKey: mutationKey,
1247 gcTime: 0,
1248 onSuccess,
1249 onSettled,
1250 }))
1251
1252 return (
1253 <div>
1254 <button
1255 onClick={() =>
1256 mutation.mutate('todo', {
1257 onSuccess: onSuccessMutate,
1258 onSettled: onSettledMutate,
1259 })
1260 }
1261 >
1262 mutate
1263 </button>
1264 <div>
1265 data: {mutation.data ?? 'null'}, status: {mutation.status},
1266 isPaused: {String(mutation.isPaused)}
1267 </div>
1268 </div>
1269 )
1270 }
1271
1272 const rendered = renderWithClient(queryClient, () => <Page />)
1273

Callers

nothing calls this directly

Calls 3

sleepFunction · 0.90
useMutationFunction · 0.50
mutateMethod · 0.45

Tested by

no test coverage detected