Add loading spinner to ThingsHistory component
This commit is contained in:
parent
568f86acd0
commit
d56c7a3bb4
1 changed files with 6 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue