fix: clear product image URL from window object on component unmount to prevent memory leaks

This commit is contained in:
sebseb7
2025-07-23 08:36:13 +02:00
parent d16e979771
commit 602324b1fe

View File

@@ -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];