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

Function Example

examples/solid/devtools-panel/src/index.tsx:31–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31function Example() {
32 const query = useQuery(() => reposQueries.detail())
33
34 return (
35 <Switch>
36 <Match when={query.isPending}>Loading...</Match>
37 <Match when={query.isError}>
38 {`An error has occurred: ${query.error?.message}`}
39 </Match>
40 <Match when={query.data}>
41 {(data) => (
42 <div
43 style={{
44 'padding-bottom': '20px',
45 }}
46 >
47 <h1>{data().full_name}</h1>
48 <p>{data().description}</p>
49 <strong>👀 {data().subscribers_count}</strong>{' '}
50 <strong>✨ {data().stargazers_count}</strong>{' '}
51 <strong>🍴 {data().forks_count}</strong>
52 <div>{query.isFetching ? 'Updating...' : ''}</div>
53 </div>
54 )}
55 </Match>
56 </Switch>
57 )
58}
59
60const rootElement = document.getElementById('root')
61if (!rootElement) throw new Error('Missing #root element')

Callers

nothing calls this directly

Calls 1

useQueryFunction · 0.90

Tested by

no test coverage detected