title: What is the difference between adding listener to componentWillMount vs componentDidMount?
body: <p>I'm trying to add a internet connection change listener to React Native app. I want to run this listener function before the render happens. So the perfect place should be <code>componentWillMount</code>. But I see most of the listeners are added to <code>componentDidMount</code>. Is there any reason for this?</p>
  <p>My code is as follows.</p>
  <pre><code>import NetInfo from '@react-native-community/netinfo';
  
  class App extends React.PureComponent {
    constructor(props) {
      super(props);
      this.unsubscribe = null;
    }
  
    componentWillMount() {
      this.unsubscribe = NetInfo.addEventListener(this.handleNetChange);
    }
    
    componentDidMount(){
      this.unsubscribe = NetInfo.addEventListener(this.handleNetChange);
    }
  
    componentWillUnmount(){
      this.unsubscribe()
    }
  
    handleNetChange(netState){
      // dispatch connection has changed
    }
  }
  </code></pre>