first-start / src /entities /Post /lib /query /useFetchPostById.tsx
Артем Леванов
first commit
41a71fd
raw
history blame contribute delete
330 Bytes
import { useQuery } from '@tanstack/react-query';
import { fetchPostById } from '../../api/fetchPostById';
export const useFetchPostById = (postId: number | undefined) => {
return useQuery({
queryKey: ['fetchPostById', postId],
queryFn: () => fetchPostById(postId || 1),
enabled: !!postId,
});
};