snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<script lang="ts">
|
||||
import type { QueryClient, QueryKey } from '@tanstack/query-core'
|
||||
import { createMutation, setQueryClientContext } from '../../src/index.js'
|
||||
import { sleep } from '@tanstack/query-test-utils'
|
||||
|
||||
type Props = {
|
||||
queryClient: QueryClient
|
||||
queryKey: QueryKey
|
||||
}
|
||||
|
||||
const { queryClient, queryKey }: Props = $props()
|
||||
|
||||
setQueryClientContext(queryClient)
|
||||
|
||||
const mutation = createMutation(() => ({
|
||||
mutationFn: (_text: string, context) =>
|
||||
sleep(10).then(() => context.client.getQueryData(queryKey)),
|
||||
}))
|
||||
</script>
|
||||
|
||||
<button onclick={() => mutation.mutate('todo')}>Mutate</button>
|
||||
|
||||
<div>data: {mutation.data}</div>
|
||||
Reference in New Issue
Block a user