Trying to retrieve a list of numbers for which will be used later on to retrieve more data.
const [listData, setList] = React.useState();
let tempSim = Temp();
const setLog = async() => {
const array = [];
const date = getDate();
const dbCon = database.ref('Conditions/Log/Temp/' + date);
await dbCon.get().then((snapshot => {
snapshot.forEach(data => {
array.push(data)
})
}))
dbCon.off()
console.log(array)
setList(array)
console.log(listData)
}
The array prints fine with all the correct data, however as soon as I set the state and try print that the only output I've been able to get is undefined?