title: How do I unsubscribe from a Firestore listener in React-Native?
body: <p>How do I unsubscribe from a Firestore listener in React-Native? I have a function where I am fetching and listening to changes in Firestore:</p>
  
  <pre><code>_fetchPatientsList() {
          var query = firestore().collection('Collection').doc().collection('public');
          query = query.where('act', '==', 1);
          query = query.where('city', '==', this.state.selected_city);
          query = query.orderBy('update_time', 'desc');
          query = query.limit(10);
  
          query.onSnapshot({
              error: (e) =&gt; this.setState({ errorMessage: e, refreshingPatients: false }),
              next: (querySnapshot) =&gt; {
                  ///do something      
              },
          });
   }
  </code></pre>
  
  <p>And I would like to unsubscribe when I log out:</p>
  
  <pre><code>    _logOutHandler = () =&gt; {
      auth()
          .signOut()
          .then(() =&gt; {
              console.log('User signed out!')
          });
      let unsub = firestore().collection('Collection').doc().collection('public').onSnapshot(() =&gt; {
      });
  
      // Stop listening for changes
      unsub();
  }
  </code></pre>
  
  <p>Is this the proper way of doing it?</p>