Skip to content

Commit

Permalink
fix: show loading spinner while waiting for data
Browse files Browse the repository at this point in the history
This avoids a blank looking dashboard item when analytics takes some
time.
  • Loading branch information
edoardo committed Mar 12, 2024
1 parent cf9690e commit 5aeae69
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CenteredContent, CircularLoader, Layer } from '@dhis2/ui'
import { CenteredContent, CircularLoader, ComponentCover } from '@dhis2/ui'
import React, { useCallback, useEffect, useState } from 'react'
import { VisualizationPlugin } from '../VisualizationPlugin/VisualizationPlugin.js'

// handle internal state for features that need to work without the app's Redux store
const VisualizationPluginWrapper = (props) => {
const [pluginProps, setPluginProps] = useState(props)
const [isLoading, setIsLoading] = useState(false)
const [isLoading, setIsLoading] = useState(true)

const onDataSorted = useCallback(
(sorting) => {
Expand Down Expand Up @@ -34,11 +34,11 @@ const VisualizationPluginWrapper = (props) => {
return (
<>
{isLoading && (
<Layer>
<ComponentCover>
<CenteredContent>
<CircularLoader />
</CenteredContent>
</Layer>
</ComponentCover>
)}
<VisualizationPlugin
{...pluginProps}
Expand Down

0 comments on commit 5aeae69

Please sign in to comment.