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

Function Component

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

Source from the content-addressed store, hash-verified

1255 }
1256
1257 function Component() {
1258 const mutation = useMutation(() => ({
1259 mutationFn: async (_text: string) => {
1260 count++
1261 await sleep(10)
1262 return count
1263 },
1264 mutationKey: mutationKey,
1265 gcTime: 0,
1266 onSuccess,
1267 onSettled,
1268 }))
1269
1270 return (
1271 <div>
1272 <button
1273 onClick={() =>
1274 mutation.mutate('todo', {
1275 onSuccess: onSuccessMutate,
1276 onSettled: onSettledMutate,
1277 })
1278 }
1279 >
1280 mutate
1281 </button>
1282 <div>
1283 data: {mutation.data ?? 'null'}, status: {mutation.status},
1284 isPaused: {String(mutation.isPaused)}
1285 </div>
1286 </div>
1287 )
1288 }
1289
1290 const rendered = renderWithClient(queryClient, () => <Page />)
1291

Callers

nothing calls this directly

Calls 3

sleepFunction · 0.90
useMutationFunction · 0.50
mutateMethod · 0.45

Tested by

no test coverage detected