removeAllListeners() doesn't work


#1

For some reason realm.removeAllListeners() doesn’t work on my react native app
This is how I set the listener up on componentWillMount()

componentWillMount(){
    realm.objects(InboxSchema.name).filtered(`id = "${this.state.userID}"`).addListener((inboxes, changes) => {
      console.warn("called")
      if(!inboxes[0]) return;
      this.setState({messages:inboxes[0].messages})
    });
}

There it works fine. I can see the warning called and the inbox is populated nicely. Now on componentWillUnmount

componentWillUnmount(){
    realm.removeAllListeners();
    console.warn("all listeners removed")
 }

That’s how I remove all listeners. I get the message “all listeners removed” just fine. But the problem is the listeners haven;t been removed because when I go back to a different screen after the method has been called, when a change happens. I still get a warning “called” being printed, meaning the listener is still there. And another warning from react that I’m trying to update a view that’s already been unmounted.