import React, { useState, useEffect, useContext } from 'react'; import { HARDWARE_STATS, fetchData, FETCH_INTERVAL } from './utils/apis'; import { BroadcastStatusContext } from './utils/broadcast-status-context'; export default function HardwareInfo() { const context = useContext(BroadcastStatusContext); const { broadcastActive } = context || {}; const [hardwareStatus, setHardwareStatus] = useState({}); const getHardwareStatus = async () => { try { const result = await fetchData(HARDWARE_STATS); console.log("hardare result", result) setHardwareStatus({ ...result }); } catch (error) { setHardwareStatus({ ...hardwareStatus, message: error.message }); } }; useEffect(() => { let getStatusIntervalId = null; getHardwareStatus(); getStatusIntervalId = setInterval(getHardwareStatus, FETCH_INTERVAL); //runs every 1 min. // returned function will be called on component unmount return () => { clearInterval(getStatusIntervalId); } }, []); return (

Hardware Info

cpu:[], disk: [], memory: []; value = %age.

the times should be the same for each, though milliseconds differ

{JSON.stringify(hardwareStatus)}
); }