0

I can already get all of the users in a collection. But I want to add all of it and show the total number of users. I am using firebase firestore.

class Users extends Component {
    state = { user : null}

    //sample on how to get collection of users
    componentDidMount() {
        firestore.collection('users')
            .get()
            .then( snapshot => {
                const users = []
                snapshot.forEach(doc => {
                    const data = doc.data()
                    users.push(data)
                })
                this.setState({ users : users})
                // console.log(snapshot)
            })
        .catch(error => console.log(error))
    }   
JS3
  • 1,623
  • 3
  • 23
  • 52

0 Answers0