import { Switch, Match, Show, For } from 'solid-js'
function Todos() {
const todosQuery = useQuery(() => ({
queryKey: ['todos'],
queryFn: fetchTodos,
}))
return (
<Switch>
<Match when={todosQuery.isPending}>
<span>Loading...</span>
</Match>
<Match when={todosQuery.isError}>
<span>Error: {todosQuery.error.message}</span>
</Match>
<Match when={todosQuery.isSuccess}>
<Show when={todosQuery.isFetching}>
<div>Refreshing...</div>
</Show>
<div>
<For each={todosQuery.data}>{(todo) => <Todo todo={todo} />}</For>
</div>
</Match>
</Switch>
)
}