(props: {
setActiveProject: (project: string | null) => void
})
| 5 | import Spinner from './Spinner' |
| 6 | |
| 7 | export 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 | } |
nothing calls this directly
no test coverage detected