This commit is contained in:
Ren Amamiya
2023-06-22 10:45:45 +07:00
parent eaaf0e0e8a
commit 7b09dc3147
23 changed files with 285 additions and 124 deletions

View File

@@ -1,8 +1,14 @@
import { DEFAULT_AVATAR } from "@stores/constants";
import { ClassAttributes, ImgHTMLAttributes, JSX } from "react";
export function Image(props) {
const addImageFallback = (event) => {
event.currentTarget.src = DEFAULT_AVATAR;
export function Image(
props: JSX.IntrinsicAttributes &
ClassAttributes<HTMLImageElement> &
ImgHTMLAttributes<HTMLImageElement>,
fallback = undefined,
) {
const addImageFallback = (event: { currentTarget: { src: string } }) => {
event.currentTarget.src = fallback ? fallback : DEFAULT_AVATAR;
};
return (