Button works but does not display first photo unless clicked twice. Works well for all subsequent uploads...code below:
function addImage(photo) {
setAlbum([...album, photo]);
}
function getImage() {
const imageDiv = document.getElementById('images');
const img = document.createElement('img');
img.src = URL.createObjectURL(photo);
album.forEach((photo) => {
// const img = document.createElement('img');
// document.createElement('img');
imageDiv.appendChild(img);
// img.src = URL.createObjectURL(photo);
});
}
function showImage() {
const fileInput = document.getElementById('myFile');
addImage(photo);
if(fileInput.files.length === 1) {
getImage();
console.log('worked')
console.log(photo)
// getImage();
// addImage(fileInput.files[0]);
} else {
console.log('fail')
}
}