MCPcopy Index your code
hub / github.com/FirebaseExtended/reactfire / INTERNALStorageImage

Function INTERNALStorageImage

src/storage.tsx:51–76  ·  view source on GitHub ↗
(props: StorageImageProps & React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>)

Source from the content-addressed store, hash-verified

49}
50
51function INTERNALStorageImage(props: StorageImageProps & React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>): JSX.Element {
52 let { storage, storagePath, suspense, placeHolder, ...imgProps } = props;
53
54 const reactfireOptions: ReactFireOptions<string> = {
55 suspense: useSuspenseEnabledFromConfigAndContext(suspense),
56 };
57
58 if (!storage) {
59 throw new Error('Storage was not passed to component INTERNALStorageImage. This should not be possible');
60 }
61
62 const { status, data: imgSrc } = useStorageDownloadURL(ref(storage, storagePath), reactfireOptions);
63
64 if (status === 'success') {
65 if (!(imgProps.alt || imgProps.alt === '')) {
66 console.warn(
67 `No alt prop provided for StorageImage with storagePath "${storagePath}"`,
68 'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images'
69 );
70 }
71
72 return <img src={imgSrc} alt={imgProps.alt} {...imgProps} />;
73 } else {
74 return placeHolder ?? <>''</>;
75 }
76}
77
78export function StorageImage(props: StorageImageProps & React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>) {
79 let { storage } = props;

Callers

nothing calls this directly

Tested by

no test coverage detected