fix undefined bug

This commit is contained in:
caranicas 2022-09-18 20:40:17 -04:00
parent 7f3279f20f
commit fcf5c41709
3 changed files with 12 additions and 2 deletions

View File

@ -25,6 +25,12 @@ export default function CompletedImages({
<div className={completedImagesMain}> <div className={completedImagesMain}>
{images && {images &&
images.map((image, index) => { images.map((image, index) => {
if (void 0 === image) {
console.warn(`image ${index} is undefined`);
return null;
}
return ( return (
<button <button
key={index} key={index}

View File

@ -97,8 +97,11 @@ export default function DisplayPanel() {
} }
}) })
.flat() .flat()
.reverse(); .reverse()
.filter((item) => void 0 !== item); // remove undefined items
setCompletedImages(temp); setCompletedImages(temp);
debugger;
setCurrentImage(temp[0] || null); setCurrentImage(temp[0] || null);
} else { } else {
setCompletedImages([]); setCompletedImages([]);
@ -113,6 +116,7 @@ export default function DisplayPanel() {
<CurrentDisplay image={currentImage}></CurrentDisplay> <CurrentDisplay image={currentImage}></CurrentDisplay>
</div> </div>
<div className={previousImages}> <div className={previousImages}>
<CompletedImages <CompletedImages
images={completedImages} images={completedImages}
setCurrentDisplay={setCurrentImage} setCurrentDisplay={setCurrentImage}

File diff suppressed because one or more lines are too long