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

Function Component

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

sleepFunction · 0.90
useMutationFunction · 0.50
mutateMethod · 0.45

Tested by

no test coverage detected