Skip to content

Commit

Permalink
fix: ImageWithFallback에서 state 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
chlwlstlf committed Jan 18, 2025
1 parent c20ac75 commit a30d2c5
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions frontend/src/components/common/img/ImageWithFallback.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useState } from "react";
import * as S from "@/components/common/img/ImageWithFallback.style";
import { errorCharacter } from "@/assets";

Expand All @@ -14,13 +13,12 @@ const ImageWithFallback = ({
fallbackSrc = errorCharacter,
...props
}: ImageWithFallbackProps) => {
const [isFallback, setIsFallback] = useState(!src);
const isFallback = !src;

const handleError = (e: React.SyntheticEvent<HTMLImageElement, Event>) => {
const img = e.target as HTMLImageElement;
img.onerror = null;
img.src = fallbackSrc;
setIsFallback(true);
};

return (
Expand Down

0 comments on commit a30d2c5

Please sign in to comment.