okay so I'm fetching data from Firestore in componentDidMount but while it's fetching the data if I change the component I get error saying:
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
In Firebase real time database we call ref.off()
to stop query.
Wondering how to do it in Firestore
componentDidMount() {
Users.get().then(({ docs }) => {
const users = docs.map(user => user.data());
this.setState({ users });
});
}
componentWillUnmount(){
}