diff --git a/src/common/component/Avatar.tsx b/src/common/component/Avatar.tsx index c25bc7fb..46a33c93 100644 --- a/src/common/component/Avatar.tsx +++ b/src/common/component/Avatar.tsx @@ -1,4 +1,4 @@ -import { FC, ImgHTMLAttributes, useEffect, useState } from "react"; +import { FC, ImgHTMLAttributes, useState } from "react"; import { getInitials } from "../utils"; interface Props extends ImgHTMLAttributes { @@ -29,17 +29,12 @@ const Avatar: FC = ({ height, ...rest }) => { - const [avatarSrc, setAvatarSrc] = useState(""); - useEffect(() => { - if (src) { - setAvatarSrc(src); - } - }, [src]); + const [error, setError] = useState(false); const handleError = () => { - setAvatarSrc(""); + setError(true); }; - if (avatarSrc) { - return ; + if (!error && src) { + return ; } return (