File size: 330 Bytes
41a71fd
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
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,
    });
};