Skip to content

Commit

Permalink
refactor: updated component logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekep-Obasi committed Nov 29, 2023
1 parent daa9a09 commit 8c1893c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/components/DataRetriever/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Splash handleLoading={setLoading} />
}

if (data === null) {
return null
}

return <>{loading ? <Splash handleLoading={setLoading} /> : children}</>
return children
}

export const useGraphData = () => {
Expand Down

0 comments on commit 8c1893c

Please sign in to comment.