This commit is contained in:
Andrés Uribe Stengel 2020-07-11 12:40:58 +02:00
commit b99ca3cefe

View File

@ -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