I'm doing a react/firebase course and following the instructor code as below. I looked for any typo errors and not sure why im getting the
images is not defined
error
componentDidMount() {
this.getImages()
}
getImages = async() => {
let imagesInRTDB = firebase.database().ref('classification/newPhotos').orderByChild('viewed').equalTo(false)
await imagesInRTDB.on('value',(snapshot) => {
let images = []
snapshot.forEach((childSnapshot) => {
let childKey = childSnapshot.key
let childData = childSnapshot.val();
childData.rtdbkey = childKey
images.push(childData)
})
})
if(images.length > 0) {
this.setState({
imagesThatNeedInference: images,
nextImage: [images.length - 1],
currentImageFb: images[images.length - 1].url
})
}
}