Answer the question
In order to leave comments, you need to log in
How to use useEffect instead of componentDidMount and componentWillUnmount?
Hello, how to rewrite such code on useEffect? Thanks in advance
state = {
authUser: null,
};
componentDidMount() {
this.listener = this.props.firebase.auth.onAuthStateChanged(
authUser => {
authUser
? this.setState({ authUser })
: this.setState({ authUser: null });
},
);
}
componentWillUnmount() {
this.listener();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question