Add loading spinner to ThingsHistory component
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
|||||||
YAxis,
|
YAxis,
|
||||||
} from 'recharts'
|
} from 'recharts'
|
||||||
import { GetThingHistory } from '../../utils/Fetcher'
|
import { GetThingHistory } from '../../utils/Fetcher'
|
||||||
|
import LoadingComponent from '../components/Loading'
|
||||||
|
|
||||||
const ThingsHistory = () => {
|
const ThingsHistory = () => {
|
||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
@@ -75,6 +76,11 @@ const ThingsHistory = () => {
|
|||||||
|
|
||||||
return `${timeValue} ${unit}${timeValue !== 1 ? 's' : ''}`
|
return `${timeValue} ${unit}${timeValue !== 1 ? 's' : ''}`
|
||||||
}
|
}
|
||||||
|
// if loading show loading spinner:
|
||||||
|
if (thingsHistory.length === 0) {
|
||||||
|
return <LoadingComponent />
|
||||||
|
}
|
||||||
|
|
||||||
if (errLoading || !thingsHistory || thingsHistory.length === 0) {
|
if (errLoading || !thingsHistory || thingsHistory.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Container
|
<Container
|
||||||
|
|||||||
Reference in New Issue
Block a user