fix: build error for checking packages
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { type ApiResponse } from '@/types/apiResponse';
|
||||
|
||||
// Define options for the hook
|
||||
interface UseApiOptions {
|
||||
// If true, the API call will be executed immediately on mount
|
||||
immediate?: boolean;
|
||||
}
|
||||
|
||||
export function useApi<T extends ApiResponse, P extends any[]>(
|
||||
export function useApi<T, P extends any[]>(
|
||||
apiFunction: (...args: P) => Promise<{ data: T }>,
|
||||
options: UseApiOptions = {},
|
||||
) {
|
||||
const [data, setData] = useState<T | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<unknown>(null);
|
||||
|
||||
const execute = useCallback(
|
||||
async (...args: P) => {
|
||||
setLoading(true);
|
||||
|
||||
Reference in New Issue
Block a user