UNPKG

react-firehooks

Version:

Lightweight dependency-free collection of React hooks for Firebase

15 lines (14 loc) 744 B
import { getMetadata } from "firebase/storage"; import { useGet } from "../internal/useGet.js"; import { isStorageRefEqual } from "./internal.js"; /** * Returns the metadata of a Google Cloud Storage object * @param reference Reference to a Google Cloud Storage object * @returns Metadata, loading state, and error * - value: Metadata; `undefined` if metadata is currently being fetched, or an error occurred * - loading: `true` while fetching the metadata; `false` if the metadata was fetched successfully or an error occurred * - error: `undefined` if no error occurred */ export function useMetadata(reference) { return useGet(reference !== null && reference !== void 0 ? reference : undefined, getMetadata, isStorageRefEqual); }