added comment to use effect for fetching data
This commit is contained in:
parent
829769501c
commit
851972304d
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user