aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-12-04 19:36:34 +0100
committerArmand Philippot <git@armandphilippot.com>2023-12-07 19:11:59 +0100
commite9d5a40432c451090e17859c764e52a96120b712 (patch)
treeff1723110920385e3888d327231c61b781921868 /src/utils
parent53b63ac27c2275262db9a04be02210a3287aa71d (diff)
refactor(pages): refine Search page
* extract NoResults component to improve readability * provide a different message when the url does not contain a query * use hooks to refresh Thematics and Topics lists * remove useDataFromApi hook
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/hooks/index.ts1
-rw-r--r--src/utils/hooks/use-data-from-api.tsx21
2 files changed, 0 insertions, 22 deletions
diff --git a/src/utils/hooks/index.ts b/src/utils/hooks/index.ts
index 1e0bfe3..1ee513d 100644
--- a/src/utils/hooks/index.ts
+++ b/src/utils/hooks/index.ts
@@ -4,7 +4,6 @@ export * from './use-articles-list';
export * from './use-boolean';
export * from './use-breadcrumb';
export * from './use-comments';
-export * from './use-data-from-api';
export * from './use-form';
export * from './use-github-api';
export * from './use-headings-tree';
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;
-};