Files
js/hooks/useImageFileOrUrl.ts
T
Jonas Daniels cb3575faa1 chore: Update API endpoint for fetching chains (#2169)
* chore: Update API endpoint for fetching chains

* prettier fixes?

* stop fighting me prettier please :)
2024-02-01 21:00:24 +00:00

16 lines
351 B
TypeScript

import { useMemo } from "react";
import { isBrowser } from "utils/isBrowser";
export function useImageFileOrUrl(image?: string | File): string {
return useMemo(() => {
if (!image) {
return "";
}
return typeof image === "string"
? image
: isBrowser()
? URL.createObjectURL(image)
: "";
}, [image]);
}