From the course: React: Cloud-Powered Apps with Firebase

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Displaying user document

Displaying user document

From the course: React: Cloud-Powered Apps with Firebase

Start my 1-month free trial

Displaying user document

- In our profile component, let's display the newly created information. Well, we'll need to get a reference to the document in our firestore, heading out to the profile component, let's import the firestore service that we previously exported from firebase/config. We will also go ahead and import use effect and you state from react. We will need a new piece of state that will hold our user document. And the initial value will be null. To retrieve the user document, we will use an effect. And this effect will depend on the user ID property. Next, we need to get a reference to the user document. We can do that by calling the collection method on the firestore service, the collection will be the users and then call the doc method with the user ID. Now to read the data, there are actually two ways we can read the data once or listen for real time changes. I will show you how to implement both. Let's first read…

Contents