From 3453d687b5d8fe24ab8cdbad7ade9b6ce540b9ad Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Thu, 10 Aug 2023 09:54:05 +0300 Subject: [PATCH] Remove useEffect and useState --- src/components/ShadowBox.tsx | 5 +++-- src/components/deviceCPULoad.tsx | 16 +++------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/components/ShadowBox.tsx b/src/components/ShadowBox.tsx index d427a493..ce14ff83 100644 --- a/src/components/ShadowBox.tsx +++ b/src/components/ShadowBox.tsx @@ -2,17 +2,18 @@ import { ReactNode } from 'react' import { Stack } from 'tamagui' type ShadowBoxProps = { + boxStyle?: React.CSSProperties children: ReactNode } -const ShadowBox = ({ children }: ShadowBoxProps) => { +const ShadowBox = ({boxStyle, children }: ShadowBoxProps) => { return ( {children} diff --git a/src/components/deviceCPULoad.tsx b/src/components/deviceCPULoad.tsx index 7b7e4099..8e30234f 100644 --- a/src/components/deviceCPULoad.tsx +++ b/src/components/deviceCPULoad.tsx @@ -1,5 +1,3 @@ -import { useState, useEffect } from 'react' - import StandartLineChart from './StandardLineChart' import ShadowBox from './ShadowBox' import IconText from './IconText' @@ -62,17 +60,11 @@ const data = [ }, ] const DeviceCPULoad = () => { - const [message, setMessage] = useState('') const currentLoad = data[0].data[data[0].data.length - 1].y - console.log(currentLoad) + const message = currentLoad < 80 ? 'Good' : 'Poor' - useEffect(() => { - currentLoad < 80 ? setMessage('Good') : setMessage('Poor') - }, [currentLoad]) - - console.log(currentLoad) return ( - + {
- CPU @@ -93,14 +84,13 @@ const DeviceCPULoad = () => { {currentLoad} GB - {message}
{message} - {/*THIS IS USED FOR ADDITIONAL TEXT {'GOod'} */} + {/* This is additional text */}