diff --git a/imports/ui/Home.jsx b/imports/ui/Home.jsx index a7868c6..10540ed 100644 --- a/imports/ui/Home.jsx +++ b/imports/ui/Home.jsx @@ -18,13 +18,14 @@ export default function Home(props) { const [sensorCardValues, setSensorCardValues] = useState(updateCardValues); const [dataHistory, setDataHistory] = useState(props.dummyData); // for init data - // runs when the app mounts + // runs when the app mounts, similiar to componentDidMount and componentDidUpdate // if you give a prop to useEffect, it also runs each time this prop changes.. useEffect(() => { + // const data = await fetch('api-address') // fetch data from db here and destructure it console.log("data is changing, start rerender..") setDataHistory(props.dummyData); setSensorCardValues(updateCardValues); - }, [props.dummyData]) + }, []) // render the data // make sensorCarddeck responsive