From 412b1cedd8f670202173efdac00f0cf574f4a928 Mon Sep 17 00:00:00 2001 From: Yuki Kobayashi <137767097+aster-void@users.noreply.github.com> Date: Mon, 11 Nov 2024 23:31:03 +0900 Subject: [PATCH] use object (#474) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # PRの概要 ## 具体的な変更内容 ## 影響範囲 ## 動作要件 ## 補足 ## レビューリクエストを出す前にチェック! - [ ] 改めてセルフレビューしたか - [ ] 手動での動作検証を行ったか - [ ] server の機能追加ならば、テストを書いたか - 理由: 書いた | server の機能追加ではない - [ ] 間違った使い方が存在するならば、それのドキュメントをコメントで書いたか - 理由: 書いた | 間違った使い方は存在しない - [ ] わかりやすいPRになっているか --- web/bun.lockb | Bin 158550 -> 158550 bytes web/components/ImageFallback.tsx | 37 +++++++++++--------------- web/components/human/WithFallback.tsx | 1 - web/public/avatar.svg | 6 +++++ 4 files changed, 22 insertions(+), 22 deletions(-) create mode 100755 web/public/avatar.svg diff --git a/web/bun.lockb b/web/bun.lockb index 120c913dc4d3cf5bc1451b16e7e8c6d1bbc666cc..d5338f3e146ed596e48fa53dfe1b0874ba9c6f2a 100755 GIT binary patch delta 25 hcmcb1jq}5JJJ<4pC8^$fP>EoOXi8~}~Q3VZ+n delta 25 dcmcb1jq}5JK!7{FkA-eSfV#{q!M2`c~q diff --git a/web/components/ImageFallback.tsx b/web/components/ImageFallback.tsx index f31e65f4..9e449b9e 100644 --- a/web/components/ImageFallback.tsx +++ b/web/components/ImageFallback.tsx @@ -1,29 +1,23 @@ "use client"; - -import { useEffect, useState } from "react"; - type Props = { url?: string; fallback: React.ReactElement; width: string; height: string; - alt: string; }; // https://medium.com/@abhishekmicosoft/handling-img-fallback-307653b2f30 -export function ImageFallback({ width, height, url, fallback, alt }: Props) { - const [ok, setOK] = useState(true); - useEffect(() => { - url; - setOK(true); - }, [url]); +export function ImageFallback({ width, height, url }: Props) { const URL = url?.startsWith("/") ? `${process.env.NEXT_PUBLIC_API_ENDPOINT}${url}` : url; - return ok ? ( - { - console.log("failed to fetch image data of:", URL); - setOK(false); - }} - alt={alt} - /> - ) : ( - <>{fallback} + > + + ); } diff --git a/web/components/human/WithFallback.tsx b/web/components/human/WithFallback.tsx index 2e2f92a9..f9d3981e 100644 --- a/web/components/human/WithFallback.tsx +++ b/web/components/human/WithFallback.tsx @@ -18,7 +18,6 @@ export function AvatarWithFallback({ width, height, url }: Props) { sx={{ width: `${width}`, height: `${height}`, objectFit: "cover" }} /> } - alt="" /> ); } diff --git a/web/public/avatar.svg b/web/public/avatar.svg new file mode 100755 index 00000000..ac3aa6fe --- /dev/null +++ b/web/public/avatar.svg @@ -0,0 +1,6 @@ + +