ychi / fire-elect

1 stars 3 forks source link

feat(firebase): add firebase Context #11

Closed ichiaohsu closed 4 years ago

ichiaohsu commented 4 years ago

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

  1. 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

  1. .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

ychi commented 4 years ago

Looks great! A few nits: