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

Function Projects

examples/solid/suspense/src/components/Projects.tsx:7–44  ·  view source on GitHub ↗
(props: {
  setActiveProject: (project: string | null) => void
})

Source from the content-addressed store, hash-verified

5import Spinner from './Spinner'
6
7export default function Projects(props: {
8 setActiveProject: (project: string | null) => void
9}) {
10 const queryClient = useQueryClient()
11 const projectsQuery = useQuery(() => ({
12 ...projectsQueries.list(),
13 throwOnError: true,
14 }))
15
16 return (
17 <div>
18 <h1>
19 TanStack Repositories{' '}
20 <Show when={projectsQuery.isFetching}>
21 <Spinner />
22 </Show>
23 </h1>
24 <For each={projectsQuery.data}>
25 {(project) => (
26 <p>
27 <Button
28 onClick={() => {
29 // Prefetch the project query
30 queryClient
31 .query(projectsQueries.detail(project.full_name))
32 .catch(noop)
33 props.setActiveProject(project.full_name)
34 }}
35 >
36 Load
37 </Button>{' '}
38 {project.name}
39 </p>
40 )}
41 </For>
42 </div>
43 )
44}

Callers

nothing calls this directly

Calls 3

useQueryClientFunction · 0.90
useQueryFunction · 0.90
queryMethod · 0.45

Tested by

no test coverage detected