Open History to see the last commit
1import { queryOptions } from '@tanstack/react-query'
2β
3// β
passes: queryKey and queryFn are co-located via queryOptions()
4export const todosOptions = queryOptions({
5 queryKey: ['todos'],
6 queryFn: () => fetchTodos(),
7})
8β
9// β
passes: factory function wrapping queryOptions()
10export const todoOptions = (id: string) =>
11 queryOptions({
12 queryKey: ['todo', id],
13 queryFn: () => fetchTodo(id),
14 })
15β
16function fetchTodos(): Promise<Array<{ id: string; title: string }>> {
17 throw new Error('not implemented')
18}
19β
20// eslint-disable-next-line @typescript-eslint/no-unused-vars
21function fetchTodo(id: string): Promise<{ id: string; title: string }> {
22 throw new Error('not implemented')
23}