"use client"; import { AspectRatio, Box, Center, Image } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import { useState } from "react"; import ComponentGlobal_Loader from "./loader"; type IRadius = "xs" | "sm" | "md" | "lg" | "xl"; export function ComponentGlobal_LoadImage({ url, maw, h, radius, }: { url: string; maw?: number | string; h?: number; radius?: IRadius; }) { const [isImage, setIsImage] = useState(null); useShallowEffect(() => { onLoadImage(); }, []); async function onLoadImage() { try { const res = await fetch(url); if (res.ok) { return setIsImage(true); } setIsImage(false); } catch (error) { console.log(error); } } if (isImage === null) return (
); if (!isImage) return ( <>
No Image
); return ( <>
Image
); }