This is my componentDidMount
method. I want to set the state of the current user and then call the function when that user is set. How can I do this?
componentDidMount = () => {
firebase.auth().onAuthStateChanged((user) => {
if (user) {
this.setState({user: user})
}
});
this.props.retrieveMatches(this.state.user.uid)
}
I've tried using async/await but im not using it correctly here:
async componentDidMount = () => {
await firebase.auth().onAuthStateChanged((user) => {
if (user) {
this.setState({user: user})
}
});
this.props.retrieveMatches(this.state.user.uid)
}
basically I want to await for lines 2-6 before calling the props function on line 7