From 8c1893c88fecd7f3d10186f4bebdfecc0a6a0d4d Mon Sep 17 00:00:00 2001 From: ARREY-ETTA BESSONG EKEP OBASI Date: Wed, 29 Nov 2023 18:00:47 +0100 Subject: [PATCH] refactor: updated component logic --- src/components/DataRetriever/index.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/DataRetriever/index.tsx b/src/components/DataRetriever/index.tsx index ebc10f3e3..62ac3644a 100644 --- a/src/components/DataRetriever/index.tsx +++ b/src/components/DataRetriever/index.tsx @@ -9,25 +9,20 @@ import { PATHWAY_RANGE } from './constants' type Props = PropsWithChildren export const DataRetriever = ({ children }: Props) => { - const [data, fetchData] = [useDataStore((s) => s.data), useDataStore((s) => s.fetchData)] - const [loading, setLoading]= useState(false) + const fetchData = useDataStore((s) => s.fetchData) + const [loading, setLoading] = useState(false) useEffect(() => { setLoading(true) fetchData() - }, [fetchData]) - if (data === null) { + if (loading) { return } - if (data === null) { - return null - } - - return <>{loading ? : children} + return children } export const useGraphData = () => {