MCPcopy Index your code
hub / github.com/TanStack/query / useWaitQuery

Function useWaitQuery

examples/react/nextjs-suspense-streaming/src/app/page.tsx:17–34  ·  view source on GitHub ↗
(props: { wait: number })

Source from the content-addressed store, hash-verified

15}
16const baseUrl = getBaseURL()
17function useWaitQuery(props: { wait: number }) {
18 const query = useSuspenseQuery({
19 queryKey: ['wait', props.wait],
20 queryFn: async () => {
21 const path = `/api/wait?wait=${props.wait}`
22 const url = baseUrl + path
23
24 const res: string = await (
25 await fetch(url, {
26 cache: 'no-store',
27 })
28 ).json()
29 return res
30 },
31 })
32
33 return [query.data as string, query] as const
34}
35
36function MyComponent(props: { wait: number }) {
37 const [data] = useWaitQuery(props)

Callers 1

MyComponentFunction · 0.85

Calls 1

useSuspenseQueryFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…