Skip to content

Commit

Permalink
Merge pull request #587 from AFP-Medialab/586-repeated-image-fetch
Browse files Browse the repository at this point in the history
Separate effect dependencies to avoid infinite loop (#586)
  • Loading branch information
ttramb authored Sep 13, 2024
2 parents c44d484 + 24dfdc3 commit 36dcea3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/components/NavItems/tools/Gif/Components/TextImageCanvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ const TextImageCanvas = ({

// loads image
useEffect(() => {
async function loadAndPreloadImage() {
const loadedImg = await preloadImage(imgSrc);
setImg(loadedImg);
}
preloadImage(imgSrc).then(setImg);
}, [imgSrc]);

loadAndPreloadImage();
useEffect(() => {
if (img) handleExport();
}, [imgSrc, img]);
}, [img]);

if (img) {
//calculates width and height used for the canvas, to have the same proportions as the image
Expand Down

0 comments on commit 36dcea3

Please sign in to comment.