From bbfd091c65c84d898ad09d1ed523b2acf2642188 Mon Sep 17 00:00:00 2001 From: jangheon Pyo Date: Thu, 18 Jul 2024 19:17:58 +0900 Subject: [PATCH] [CustomImage] Add error default image --- .../src/components/CustomImage/CustomImage.jsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/com.twin.app.shoptime/src/components/CustomImage/CustomImage.jsx b/com.twin.app.shoptime/src/components/CustomImage/CustomImage.jsx index 71b91396..da1ff9e2 100644 --- a/com.twin.app.shoptime/src/components/CustomImage/CustomImage.jsx +++ b/com.twin.app.shoptime/src/components/CustomImage/CustomImage.jsx @@ -7,8 +7,8 @@ import React, { memo, useCallback, useEffect, useRef, useState } from "react"; import classNames from "classnames"; - import css from "./CustomImage.module.less"; +import defaultImageItem from "../../../assets/images/img-thumb-empty-144@3x.png"; //animationSpeed : "slow", "normal", "fast", "none" ==> 500ms, 250ms, 10ms, 0ms export default memo(function CustomImage({ @@ -30,8 +30,8 @@ export default memo(function CustomImage({ const showImageJob = useRef(null); useEffect(() => { - if(src && src !== imgSrc){ - if(showImageJob.current){ + if (src && src !== imgSrc) { + if (showImageJob.current) { clearTimeout(showImageJob.current); showImageJob.current = null; } @@ -39,14 +39,14 @@ export default memo(function CustomImage({ setError(false); setImageLoaded(false); } - if(!src){ + if (!src) { setError(true); } }, [src]); useEffect(() => { return () => { - if(showImageJob.current){ + if (showImageJob.current) { clearTimeout(showImageJob.current); showImageJob.current = null; } @@ -54,7 +54,7 @@ export default memo(function CustomImage({ }, []); const _onLoad = useCallback(() => { - if(showImageJob.current){ + if (showImageJob.current) { clearTimeout(showImageJob.current); } showImageJob.current = setTimeout(() => { @@ -72,12 +72,12 @@ export default memo(function CustomImage({ return ( ); } - if(!imgSrc || !src){ + if (!imgSrc || !src) { return null; } return (