0

I wanna define to null. Why won't it let me do this? I'm getting a TypeError error. I think there was no such problem with older versions?I want to treat this variable like typescript?

unsubscribe: null ;

componentDidMount() {          
    const user = this.props.uid || Fire.shared.uid;

    this.unsubscribe = Fire.shared.firestore
        .collection("users")
        .doc(user)
        .onSnapshot(doc => {
            this.setState({ user: doc.data() });
        })

}

componentWillUnMount() {   // EDITED
    this.unsubscribe();
}
0

1 Answer 1

1

componentWillMount gets called before componentDidMount - this is a typo. You meant to write unsubscribe in componentWillUnmount, not componentWillMount

Sign up to request clarification or add additional context in comments.

2 Comments

Yes thanks. but still I get an error on this line ( unsubscribe: null ;). did not change the situation. What can I write instead of if we can no longer make such a demonstration?
@cantaş unsubscribe = null

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.