aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/hooks/use-data-from-api.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/hooks/use-data-from-api.tsx')
-rw-r--r--src/utils/hooks/use-data-from-api.tsx21
1 files changed, 0 insertions, 21 deletions
diff --git a/src/utils/hooks/use-data-from-api.tsx b/src/utils/hooks/use-data-from-api.tsx
deleted file mode 100644
index 5abcf09..0000000
--- a/src/utils/hooks/use-data-from-api.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { useEffect, useState } from 'react';
-
-/**
- * Fetch data from an API.
- *
- * This hook is a wrapper to `setState` + `useEffect`.
- *
- * @param fetcher - A function to fetch data from API.
- * @returns {T | undefined} The requested data.
- */
-export const useDataFromAPI = <T,>(
- fetcher: () => Promise<T>
-): T | undefined => {
- const [data, setData] = useState<T>();
-
- useEffect(() => {
- fetcher().then((apiData) => setData(apiData));
- }, [fetcher]);
-
- return data;
-};