In this pull request, I create a component FirebaseProvider providing a single initialized firebase instance that could be consumed in function React component using Hook.
RealtimeExample shows how to use the real-time firebase API, while RestfulExample is the example with Restful flavor.
What's changed
Firebase, FirebaseProvider
Firebase is a class that holds firebase.firestore() in its db field. This object was init once in App.js, and passed into FirebaseProvider as a Context.
They are in src/container/Firebase
.env file holds the credentials for firebase
Firebase credentials are stored in .env that will be bundled be webpack. This file wouldn't be uploaded to GitHub. I'll provided privately.
If you want to use your own firebase settings, you could reference the example in .env.example and create your own .env files with higher priority, e.g. .env.development
the class Firebase is actually something can be used by a container component, it is not (and does not need to be) a container component. So I will put it in a separate folder
contexts can have their own folder too. I will do it after merging.
In this pull request, I create a component
FirebaseProvider
providing a single initialized firebase instance that could be consumed in function React component using Hook.RealtimeExample
shows how to use the real-time firebase API, whileRestfulExample
is the example with Restful flavor.What's changed
db
field. This object was init once inApp.js
, and passed intoFirebaseProvider
as a Context.They are in
src/container/Firebase
.env
file holds the credentials for firebase Firebase credentials are stored in.env
that will be bundled be webpack. This file wouldn't be uploaded to GitHub. I'll provided privately.If you want to use your own firebase settings, you could reference the example in
.env.example
and create your own .env files with higher priority, e.g..env.development