mirror of
https://github.com/zhigang1992/reactfire.git
synced 2026-06-12 09:08:43 +08:00
1.7 KiB
1.7 KiB
ReactFire
Hooks that make it easy to interact with Firestore, Realtime Database, Authentication, and Storage. Note, every reactfire hook throws a Promise until it has connected to Firebase. Wrap your components in React's Suspense, or, if you don't want to deal with Suspense, pass an initial value to a reactfire hook. Example.
Usage
Authentication
useUser(auth: auth.Auth, options?: ReactFireOptions): User
Firestore
function useFirestoreDoc(
ref: firestore.DocumentReference,
options?: ReactFireOptions
): firestore.DocumentSnapshot;
function useFirestoreCollection(
ref: firestore.CollectionReference,
options?: ReactFireOptions
): firestore.QuerySnapshot;
Realtime Database
function useDatabaseObject(
ref: database.Reference,
options?: ReactFireOptions
): QueryChange;
function useDatabaseList(
ref: database.Reference | database.Query,
options?: ReactFireOptions
): QueryChange[];
Cloud Storage for Firebase
function useStorageTask(
task: storage.UploadTask,
ref: storage.Reference,
options?: ReactFireOptions
): storage.UploadTaskSnapshot;
function useStorageDownloadURL(
ref: storage.Reference,
options?: ReactFireOptions
): string;
For development
yarn installcdinto the reactfire/reactfire directory. runyarn run watch.- In a new terminal,
cdinto the reactfire/sample-simple directory. runyarn start. - Head over to https://localhost:3000 to see the running sample
Testing
cdinto the reactfire/reactfire directory- run
yarn test