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

Function Example

examples/react/devtools-panel/src/index.tsx:27–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27function Example() {
28 const { isPending, error, data, isFetching } = useQuery(reposQueries.detail())
29
30 if (isPending) return 'Loading...'
31
32 if (error) return 'An error has occurred: ' + error.message
33
34 return (
35 <div
36 style={{
37 paddingBottom: 20,
38 }}
39 >
40 <h1>{data.full_name}</h1>
41 <p>{data.description}</p>
42 <strong>👀 {data.subscribers_count}</strong>{' '}
43 <strong>✨ {data.stargazers_count}</strong>{' '}
44 <strong>🍴 {data.forks_count}</strong>
45 <div>{isFetching ? 'Updating...' : ''}</div>
46 </div>
47 )
48}
49
50const rootElement = document.getElementById('root')
51if (!rootElement) throw new Error('Missing #root element')

Callers

nothing calls this directly

Calls 1

useQueryFunction · 0.90

Tested by

no test coverage detected