mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-22 08:08:13 +00:00
feat: remove use state and effect
just calculate them without state
This commit is contained in:
parent
9a81ce2367
commit
f8e6cf8369
@ -1,5 +1,4 @@
|
||||
import { YStack } from 'tamagui'
|
||||
import { useEffect, useState } from 'react'
|
||||
import StatusIconText from './StatusIconText'
|
||||
import {
|
||||
BAD_CPU_CLOCK_RATE_TEXT,
|
||||
@ -25,16 +24,10 @@ const HealthInfoSection = (props: HealthInfoSectionProps) => {
|
||||
const { usedStorage, maxStorage, usedRamMemory, maxRamMemory, cpuClockRate, networkLatency } =
|
||||
props
|
||||
|
||||
const [usedStoragePercentage, setUsedStoragePercentage] = useState(0)
|
||||
const [usedRamMemoryPercentage, setUsedRamMemoryPercentage] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
setUsedStoragePercentage((usedStorage / maxStorage) * 100)
|
||||
}, [usedStorage, maxStorage])
|
||||
|
||||
useEffect(() => {
|
||||
setUsedRamMemoryPercentage((usedRamMemory / maxRamMemory) * 100)
|
||||
}, [usedRamMemory, maxRamMemory])
|
||||
const usedStoragePercentage = (usedStorage / maxStorage) * 100
|
||||
const usedRamMemoryPercentage = (usedRamMemory / maxRamMemory) * 100
|
||||
const cpuClockRatePercentage = cpuClockRate > 2.4 ? 100 : 0
|
||||
const networkLatencyPercentage = networkLatency > 100 ? 100 : 0
|
||||
|
||||
return (
|
||||
<YStack space={'$2'}>
|
||||
@ -45,7 +38,7 @@ const HealthInfoSection = (props: HealthInfoSectionProps) => {
|
||||
badText={BAD_STORAGE_TEXT}
|
||||
/>
|
||||
<StatusIconText
|
||||
percentage={cpuClockRate > 2.4 ? 100 : 0}
|
||||
percentage={cpuClockRatePercentage}
|
||||
threshold={50}
|
||||
goodText={GOOD_CPU_CLOCK_RATE_TEXT}
|
||||
badText={BAD_CPU_CLOCK_RATE_TEXT}
|
||||
@ -57,7 +50,7 @@ const HealthInfoSection = (props: HealthInfoSectionProps) => {
|
||||
badText={BAD_RAM_MEMORY_TEXT}
|
||||
/>
|
||||
<StatusIconText
|
||||
percentage={networkLatency > 100 ? 100 : 0}
|
||||
percentage={networkLatencyPercentage}
|
||||
threshold={50}
|
||||
goodText={GOOD_NETWORK_TEXT}
|
||||
badText={BAD_NETWORK_TEXT}
|
||||
|
Loading…
x
Reference in New Issue
Block a user