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.

Admin interface: Read user collection

Admin interface: Read user collection

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

Start my 1-month free trial

Admin interface: Read user collection

- [Instructor] Now that we have our admin route set up, let's display some users. I went ahead and added a few more users, using the sample data in the profiles folder in the project. If you need temporary email addresses, you can use something like tempmail.org. Heading back to our users component, we need to add a new piece of state and it will be an array of users. We can use the used state hook from react and the initial value will be an empty array. We can then use the use effect hook in order to retrieve our users collection. Let's first create a reference to that collection. And we can use the firestore service and retrieve the users collection. On this users reference, we can listen for real time changes using the on snapshot method. And we get back what's called a query snapshot, from Firebase. From this query snapshot, we can get the array of all the documents. We can actually map over these and…

Contents