From 7694cb3122a46f98bc6e89de2706eb3623a6b2ef Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 11 Oct 2023 10:36:01 +0530 Subject: [PATCH] Apply changes from code review --- src/Components/ExternalResult/ResultItem.tsx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Components/ExternalResult/ResultItem.tsx b/src/Components/ExternalResult/ResultItem.tsx index ec24273c114..47363e02ce1 100644 --- a/src/Components/ExternalResult/ResultItem.tsx +++ b/src/Components/ExternalResult/ResultItem.tsx @@ -11,20 +11,11 @@ import request from "../../Utils/request/request"; const Loading = lazy(() => import("../Common/Loading")); export default function ResultItem(props: any) { - const initialData: any = {}; - const [resultItemData, setResultItemData] = useState(initialData); - const [isLoading, setIsLoading] = useState(true); const [showDeleteAlert, setShowDeleteAlert] = useState(false); const { t } = useTranslation(); - useQuery(routes.externalResult, { + const { data: resultItemData, loading } = useQuery(routes.externalResult, { pathParams: { id: props.id }, - onResponse: ({ res, data }) => { - if (res?.status === 200 && data) { - setResultItemData(data); - } - setIsLoading(false); - }, }); const handleDelete = async () => { @@ -47,7 +38,7 @@ export default function ResultItem(props: any) { } }; - if (isLoading) { + if (loading || !resultItemData) { return ; }