--- id: disabling-queries title: Disabling/Pausing Queries ref: docs/framework/react/guides/disabling-queries.md --- [//]: # 'Example' ```tsx import { Switch, Match, Show, For } from 'solid-js' function Todos() { const todosQuery = useQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodoList, enabled: false, })) return (
    {(todo) =>
  • {todo.title}
  • }
Error: {todosQuery.error.message} Loading... Not ready ...
{todosQuery.isFetching ? 'Fetching...' : null}
) } ``` [//]: # 'Example' [//]: # 'Example2' ```tsx import { createSignal } from 'solid-js' function Todos() { const [filter, setFilter] = createSignal('') const todosQuery = useQuery(() => ({ queryKey: ['todos', filter()], queryFn: () => fetchTodos(filter()), // ⬇️ disabled as long as the filter is empty enabled: !!filter(), })) return (
{/* 🚀 applying the filter will enable and execute the query */}
) } ``` [//]: # 'Example2' [//]: # 'Example3' ```tsx import { createSignal } from 'solid-js' import { skipToken, useQuery } from '@tanstack/solid-query' function Todos() { const [filter, setFilter] = createSignal() const todosQuery = useQuery(() => ({ queryKey: ['todos', filter()], // ⬇️ disabled as long as the filter is undefined or empty queryFn: filter() ? () => fetchTodos(filter()!) : skipToken, })) return (
{/* 🚀 applying the filter will enable and execute the query */}
) } ``` [//]: # 'Example3'