Skip to content

Commit

Permalink
fix: Image 컴포넌트 에러 처리 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
not-using committed Aug 16, 2023
1 parent ee921ab commit 169333e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/component/utils/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ type Size = number;
type Props = HTMLProps<HTMLImageElement> & { width?: Size; height?: Size };

const Image = ({ src, alt, width, height, ...props }: Props) => {
const [error, setError] = useState(false);
return (
<img
{...props}
src={error ? fallback : src}
src={src}
alt={alt}
style={{ width, height }}
onError={() => setError(true)}
onError={e => (e.currentTarget.src = fallback)}
loading="lazy"
/>
);
Expand Down

0 comments on commit 169333e

Please sign in to comment.