basic structure setup
This commit is contained in:
commit
71dfd86187
89 files changed
+41490
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import * as api from '../lib/api';
|
||||
|
||||
export function useArticles(params: api.FindArticlesParams = {}) {
|
||||
return useQuery({
|
||||
queryKey: ['articles', params],
|
||||
queryFn: () => api.fetchArticles(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useArticle(slug: string) {
|
||||
return useQuery({
|
||||
queryKey: ['article', slug],
|
||||
queryFn: () => api.fetchArticleBySlug(slug),
|
||||
enabled: !!slug,
|
||||
});
|
||||
}
|
||||
|
||||
export function useArticleById(id: string) {
|
||||
return useQuery({
|
||||
queryKey: ['article', id],
|
||||
queryFn: () => api.fetchArticleById(id),
|
||||
enabled: !!id,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user