fix: clear product image URL from window object on component unmount to prevent memory leaks
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user