Skip to content

Commit 0aa4d65

Browse files
committed
updates to quickstart based on Sam's feedback
1 parent 2182139 commit 0aa4d65

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

README.md

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,45 @@ connected to Firebase, allowing you to use [Suspense](https://reactjs.org/docs/c
1616

1717
## Quickstart
1818

19-
Listen for realtime changes in a Firestore document with Reactfire. We'll use [`create-react-app`](https://facebook.github.io/create-react-app/docs/getting-started) to quickly get a Reactfire demo up and running.
19+
⚛ + 🔥 = 🌯
2020

21-
1. Create a fresh React app.
21+
We'll build a web app that displays, in _real time_, the tastiness of a burrito. It will listen to **Cloud Firestore** for its data, and we'll configure **Firebase Performance Monitoring** so we can get some perf stats.
22+
23+
> Prerequisite: make sure you have [Node.js](https://nodejs.org/en/) installed.
24+
25+
1. In a terminal, create a fresh React app and `cd` into its directory.
2226

2327
```shell
24-
create-react-app myapp
28+
npx create-react-app myapp
29+
cd myapp
2530
```
2631

2732
1. Install reactfire and the Firebase SDK
2833

2934
```shell
30-
npm i firebase reactfire@canary
35+
yarn add firebase reactfire@canary
3136
```
3237

33-
1. Create a world-readable document in Firestore.
38+
1. Create a document in Cloud Firestore.
39+
40+
1. Go to the _Database_ tab in the Firebase console. If your project doesn't have a Cloud Firestore instance yet, initialize it in locked mode
41+
1. Add a document
42+
43+
1. In the _Data_ tab of the console, click _Add Collection_
3444

35-
For example, a collection called **_tryreactfire_** with document **_burrito_** with field `yummy: true`.
45+
1. Name the collection **_tryreactfire_**
46+
1. Add a document with ID **_burrito_** and boolean field `yummy: true`
3647

37-
To keep this as simple as possible, modify your security rules to make that document world-readable.
48+
![new document screenshot](https://firebasestorage.googleapis.com/v0/b/rxfire-525a3.appspot.com/o/docs%2FScreen%20Shot%202019-07-03%20at%202.19.11%20PM.png?alt=media&token=052d27ea-5db1-4a02-aad0-a3f017c1a975)
49+
50+
1. Add the following to your security rules and click _Publish_
51+
52+
```text
53+
match /tryreactfire/burrito {
54+
allow read: if true;
55+
allow write: if request.auth.uid != null;
56+
}
57+
```
3858
3959
1. Modify `src/index.js`
4060
@@ -70,7 +90,11 @@ Listen for realtime changes in a Firestore document with Reactfire. We'll use [`
7090
```js
7191
//...
7292
import 'firebase/firestore';
73-
import { useFirestoreDoc, useFirebaseApp } from 'reactfire';
93+
import {
94+
useFirestoreDoc,
95+
useFirebaseApp,
96+
SuspenseWithPerf
97+
} from 'reactfire';
7498
//...
7599
```
76100
@@ -108,9 +132,12 @@ Listen for realtime changes in a Firestore document with Reactfire. We'll use [`
108132
function App() {
109133
return (
110134
<div className="App">
111-
<React.Suspense fallback={'loading burrito status...'}>
135+
<SuspenseWithPerf
136+
fallback={'loading burrito status...'}
137+
traceId={'load-burrito-status'}
138+
>
112139
<Burrito />
113-
</React.Suspense>
140+
</SuspenseWithPerf>
114141
</div>
115142
);
116143
}
@@ -125,6 +152,16 @@ Listen for realtime changes in a Firestore document with Reactfire. We'll use [`
125152

126153
1. Edit the value of `yummy` in the Firebase console, and watch it update in real time in your app! 🔥🔥🔥
127154

155+
1. _"But what about Firebase Performance Monitoring?"_
156+
157+
By passing the `initPerformance` prop to `FirebaseAppProvider`, our app will automatically measure [common performance stats](https://firebase.google.com/docs/perf-mon/automatic-web), as well as report on our custom trace, `load-burrito-status`, that we set in the `traceId` prop of `SuspenseWithPerf`.
158+
159+
However, Firebase Performance Monitoring can take about 12 hours to crunch your data and show it in the _Performance_ tab of the Firebase console.
160+
161+
This is an example of some of the stats in the Firebase Performance Monitoring console after 12 hours:
162+
163+
![Performance screenshot](https://firebasestorage.googleapis.com/v0/b/rxfire-525a3.appspot.com/o/docs%2FScreen%20Shot%202019-07-03%20at%202.43.29%20PM.png?alt=media&token=079547b5-ba5d-46bc-acfa-d9dedc184dc5)
164+
128165
## Docs
129166

130167
### ToC

0 commit comments

Comments
 (0)