Skip to content

Commit

Permalink
fix(storage): use require in useBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
andipaetzold committed Nov 19, 2021
1 parent 3f3c36c commit 9822fa0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/storage/useBytes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { StorageError, StorageReference } from "firebase/storage";
import * as firebaseStorage from "firebase/storage";
import { useCallback } from "react";
import { ValueHookResult } from "../common";
import { useOnce } from "../internal/useOnce";
Expand All @@ -22,6 +21,8 @@ export type UseBytesResult = ValueHookResult<ArrayBuffer, StorageError>;
export function useBytes(reference: StorageReference | undefined | null, maxDownloadSizeBytes?: number): UseBytesResult {
const fetchBytes = useCallback(
async (ref: StorageReference) => {
// TODO: change to regular import in react-firehooks v2
const firebaseStorage = await require("firebase/storage");
if ("getBytes" in firebaseStorage) {
return await firebaseStorage.getBytes(ref, maxDownloadSizeBytes);
} else {
Expand Down

0 comments on commit 9822fa0

Please sign in to comment.