From 602324b1fe5716d9d7cadefd946b885c1e876a8b Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Wed, 23 Jul 2025 08:36:13 +0200 Subject: [PATCH] fix: clear product image URL from window object on component unmount to prevent memory leaks --- src/components/Images.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/Images.js b/src/components/Images.js index b9520f8..a87b34d 100644 --- a/src/components/Images.js +++ b/src/components/Images.js @@ -23,6 +23,9 @@ class Images extends Component { this.updatePics(); } } + componentWillUnmount() { + window.productImageUrl = null; + } updatePics = (newMainPic = this.state.mainPic) => { if (!window.tinyPicCache) window.tinyPicCache = {}; @@ -105,6 +108,8 @@ class Images extends Component { render() { // SPA version - full functionality with static fallback const getImageSrc = () => { + if(window.productImageUrl) return window.productImageUrl; + // If dynamic image is loaded, use it if (this.state.pics[this.state.mainPic]) { return this.state.pics[this.state.mainPic];