Why is my React component is rendering twice? : <p>I don't know why my React component is rendering twice. So I am pulling a phone number from params and saving it to state so I can search through Firestore. Everything seems to be working fine except it renders twice... The first one renders the phone number and zero points. The second time it renders all the data is displayed correctly. Can someone guide me to the solution. </p>

<pre><code>class Update extends Component {
constructor(props) {
    super(props);
    const { match } = this.props;
    this.state = {
        phoneNumber: match.params.phoneNumber,
        points: 0,
        error: ''
    }
}

getPoints = () =&gt; {
    firebase.auth().onAuthStateChanged((user) =&gt; {
        if(user) {
            const docRef = database.collection('users').doc(user.uid).collection('customers').doc(this.state.phoneNumber);
            docRef.get().then((doc) =&gt; {
                if (doc.exists) {
                const points = doc.data().points;
                this.setState(() =&gt; ({ points }));
                console.log(points);
                } else {
                // doc.data() will be undefined in this case
                console.log("No such document!");
                const error = 'This phone number is not registered yet...'
                this.setState(() =&gt; ({ error }));
                }
                }).catch(function(error) {
                console.log("Error getting document:", error);
                });
        } else {
            history.push('/')
        }
    });
}

componentDidMount() {
    if(this.state.phoneNumber) {
        this.getPoints();
    } else {
        return null;
    }
}

render() {
    return (
        &lt;div&gt;
            &lt;div&gt;
                &lt;p&gt;{this.state.phoneNumber} has {this.state.points} points...&lt;/p&gt;
                &lt;p&gt;Would you like to redeem or add points?&lt;/p&gt;
            &lt;/div&gt;
            &lt;div&gt;
                &lt;button&gt;Redeem Points&lt;/button&gt;
                &lt;button&gt;Add Points&lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    );
  }
}

export default Update;
</code></pre>
