You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Move sample-simple to Concurrent Mode
* Preload a query and lazy import Firestore
* more work on async/preloading
* demonstrate useTransition
* Update docs
* add note about experimental react build
* Update rollup config
Now that we're doing lazy imports with multiple chunks,
rollup needs to output to a directory
* docs fixes
* lazy import the rest of the SDKs
* remove some extra imports
* remove some extra imports
Copy file name to clipboardExpand all lines: README.md
+7-11Lines changed: 7 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@ to interact with Firebase.
5
5
6
6
> If you're looking for docs for the _deprecated_ ReactFire v1 (the one that uses mixins), click [here](https://github.com/FirebaseExtended/reactfire/tree/v1.0.0)
7
7
8
+
**Status: Alpha**. ReactFire is meant for React Concurrent Mode, which is only available in [experimental React builds](https://reactjs.org/docs/concurrent-mode-adoption.html#installation).
9
+
8
10
## What is ReactFire?
9
11
10
12
-**Easy realtime updates for your function components** - Reactfire's hooks, like `useFirestoreCollection` and `useUser`, let you easily subscribe to events, and automatically unsubscribe when your component unmounts.
11
13
-**Loading states handled by `<Suspense>`** - Reactfire's hooks throw promises that Suspense can catch. No more `isLoaded ?...` - let React [handle it for you](https://reactjs.org/blog/2018/11/27/react-16-roadmap.html#react-166-shipped-the-one-with-suspense-for-code-splitting).
12
14
-**Dead-simple Real User Monitoring (RUM)** - Easily enable Firebase Performance Monitoring's [automatic traces](https://firebase.google.com/docs/perf-mon/automatic-web), and instrument your Suspenseful loads with Reactfire's `<SuspenseWithPerf>` component
13
15
14
-
Status: Alpha
15
-
16
16
## Install
17
17
18
18
```bash
@@ -34,33 +34,29 @@ import { render } from 'react-dom';
34
34
import'./style.css';
35
35
import {
36
36
FirebaseAppProvider,
37
-
useFirestoreDoc,
38
-
useFirebaseApp,
37
+
useFirestoreDocData,
39
38
SuspenseWithPerf
40
39
} from'reactfire';
41
40
42
41
import'firebase/performance';
43
-
import'firebase/firestore';
44
42
45
43
constfirebaseConfig= {
46
44
/* add your config object from the Firebase console */
47
45
};
48
46
49
47
functionBurrito() {
50
-
// create a ref
51
-
constfirebaseApp=useFirebaseApp();
52
-
constburritoRef= firebaseApp
53
-
.firestore()
48
+
// lazy load the Firestore SDK and create a ref
49
+
constburritoRef=useFirestore()
54
50
.collection('tryreactfire')
55
51
.doc('burrito');
56
52
57
53
// subscribe to the doc. just one line!
58
54
// throws a Promise for Suspense to catch,
59
55
// and then streams live updates
60
-
constburritoDoc=useFirestoreDoc(burritoRef);
56
+
constburrito=useFirestoreDocData(burritoRef);
61
57
62
58
// get the value from the doc
63
-
constisYummy=burritoDoc.data().yummy;
59
+
constisYummy=burrito.yummy;
64
60
65
61
return<p>The burrito is {isYummy ?'good':'bad'}!</p>;
1. Render your component inside of a `Suspense` tag
117
113
118
-
> We need to do this because `useFirestoreDoc` throws a Promise while it is waiting for a response from Firestore. Suspense will catch the Promise and render `fallback` until the Promise is resolved.
114
+
> We need to do this because `useFirestoreDocData` throws a Promise while it is waiting for a response from Firestore. Suspense will catch the Promise and render `fallback` until the Promise is resolved.
0 commit comments