From 037c943fb5aa387edf1e3a86ec263f1b5d7718fe Mon Sep 17 00:00:00 2001 From: Guido Modarelli Date: Tue, 5 Nov 2024 09:23:00 -0300 Subject: [PATCH] refactor(useGenericRequest): rename response state to data and update related logic for clarity --- .../public/components/common/hooks/useGenericRequest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/main/public/components/common/hooks/useGenericRequest.ts b/plugins/main/public/components/common/hooks/useGenericRequest.ts index dfdafb78ec..f6119b061f 100644 --- a/plugins/main/public/components/common/hooks/useGenericRequest.ts +++ b/plugins/main/public/components/common/hooks/useGenericRequest.ts @@ -22,7 +22,7 @@ export function useGenericRequest({ params = {}, resolveData = response => response, }: UseGenericRequestProps) { - const [response, setResponse] = useState({}); + const [data, setData] = useState({}); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(); @@ -35,7 +35,7 @@ export function useGenericRequest({ path, params, ); - setResponse(response); + setData(resolveData(response)); }; fetchData(); } catch (error) { @@ -58,7 +58,7 @@ export function useGenericRequest({ return { isLoading, - data: resolveData(response), + data, error, }; }