refactoring: improvements for lighthouse
This commit is contained in:
1 parent
f2f242a684
commit
38aebcbe28
27 files changed
+132
-93
No files matched your search
@@ -2,10 +2,17 @@ import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { details } from '@/api';
|
||||
|
||||
const useDetails = ({ showId, showType = 'movie' }: { showId?: Show['id']; showType?: Show['type'] }) =>
|
||||
interface Props {
|
||||
showId?: Show['id'];
|
||||
showType?: Show['type'];
|
||||
}
|
||||
|
||||
export const KEY = ({ showId, showType = 'movie' }: Props) => ['details', showId, showType];
|
||||
|
||||
const useDetails = ({ showId, showType = 'movie' }: Props) =>
|
||||
useQuery({
|
||||
enabled: Boolean(showId && showType),
|
||||
queryKey: ['details', showId, showType],
|
||||
queryKey: KEY({ showId, showType }),
|
||||
queryFn: () => details({ showId: showId!, showType })
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user