|
Download react-query/docs/framework/angular/guides/query-keys.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/query-keys.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/query-keys.md
-
curl -L -o query-keys.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/query-keys.md
1.45 kB
| id: query-keys | |
| title: Query Keys | |
| ref: docs/framework/react/guides/query-keys.md | |
| #todo: exhaustive-deps is at least for now React-only | |
| [//]: # 'Example' | |
| ```ts | |
| // A list of todos | |
| injectQuery(() => ({ queryKey: ['todos'], ... })) | |
| // Something else, whatever! | |
| injectQuery(() => ({ queryKey: ['something', 'special'], ... })) | |
| ``` | |
| [//]: # 'Example' | |
| [//]: # 'Example2' | |
| ```ts | |
| // An individual todo | |
| injectQuery(() => ({queryKey: ['todo', 5], ...})) | |
| // An individual todo in a "preview" format | |
| injectQuery(() => ({queryKey: ['todo', 5, {preview: true}], ...})) | |
| // A list of todos that are "done" | |
| injectQuery(() => ({queryKey: ['todos', {type: 'done'}], ...})) | |
| ``` | |
| [//]: # 'Example2' | |
| [//]: # 'Example3' | |
| ```ts | |
| injectQuery(() => ({ queryKey: ['todos', { status, page }], ... })) | |
| injectQuery(() => ({ queryKey: ['todos', { page, status }], ...})) | |
| injectQuery(() => ({ queryKey: ['todos', { page, status, other: undefined }], ... })) | |
| ``` | |
| [//]: # 'Example3' | |
| [//]: # 'Example4' | |
| ```ts | |
| injectQuery(() => ({ queryKey: ['todos', status, page], ... })) | |
| injectQuery(() => ({ queryKey: ['todos', page, status], ...})) | |
| injectQuery(() => ({ queryKey: ['todos', undefined, page, status], ...})) | |
| ``` | |
| [//]: # 'Example4' | |
| [//]: # 'Example5' | |
| ```ts | |
| todoId = signal(-1) | |
| injectQuery(() => ({ | |
| enabled: todoId() > 0, | |
| queryKey: ['todos', todoId()], | |
| queryFn: () => fetchTodoById(todoId()), | |
| })) | |
| ``` | |
| [//]: # 'Example5' | |
| [//]: # 'Materials' | |
| [//]: # 'Materials' | |