title: React Native ~0.61.4 Event Emitter causing crash on IOS?
body: <p>I am building a Music App where the mini player component holds the expo audio instance and it is separated from the bottom tab navigator for two important reasons : </p>
  
  <p>1 - The audio instance lives in that mini-player component so navigation won't reset it.</p>
  
  <p>2 - The mini player is global thus available in all application stack and tab navigations.</p>
  
  <p>I am using <code>NativeEventEmitter</code> to help me control the player actions (ie: Play/Pause;Next; Pervious;) since those function lives in that mini-player component and needs to be called from a stack screen inside the tab navigator ! . </p>
  
  <p>Now in <code>Android</code> it is working fine but in <code>IOS</code>, it is causing the application to crash.</p>
  
  <p>The error : </p>
  
  <blockquote>
    <p>Native Module cannot be null<br>
     - node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:36:16 in 
     App/Containers/Player/PlayerScreen.js:47:4 in _handleStop</p>
  </blockquote>
  
  <p>The Logic I am implementing here , is upon clicking on the miniPlayer component after it is mounted, I am hiding it and navigating to the <code>Player Screen</code>;</p>
  
  <blockquote>
    <p>Player Screen : </p>
  </blockquote>
  
  <pre><code>...
  class PlayerScreen extends Component {
    constructor(props) {
      super(props);
      this.eventEmitter = new NativeEventEmitter();
      this._handleNext = this._handleNext.bind(this);
      this._handlePlayPause = this._handlePlayPause.bind(this);
      this._handlePrevious = this._handlePrevious.bind(this);
      this.state = {
        time: "00:00"
      };
    }
  
    componentDidMount() {
  
    }
  
    _handlePlayPause = () =&gt; {
      this.eventEmitter.emit("PLAYPAUSE", "");
    };
  
    _handleNext = () =&gt; {
      this.eventEmitter.emit("NEXTSONG", "");
    };
  
    _handlePrevious = () =&gt; {
      this.eventEmitter.emit("PREVIOUSSONG", "");
    };
  
    _handleStop = () =&gt; {
      this.eventEmitter.emit("STOPSONG", "");
    };
  ...
  render()
  ....
  </code></pre>
  
  <blockquote>
    <p>MiniPlayer Component :</p>
  </blockquote>
  
  <pre><code>componentDidMount() {
      this.listener = DeviceEventEmitter.addListener("PLAYPAUSE", data =&gt; {
        this._handlePlayAndPause();
        console.log("New Event is registered At Listeners PLAY_PAUSE");
  
      });
      this.listenerN = DeviceEventEmitter.addListener("NEXTSONG", data =&gt; {
        this._handleNextSong()
        console.log("New Event is registered At Listeners NEXT_SONG ");
  
      });
      this.listenerP = DeviceEventEmitter.addListener("PREVIOUSSONG", data =&gt; {
       this._handlePreviousSong()
        console.log("New Event is registered At Listeners PREVIOUS_SONG");
  
      });
  
      this.listenerS = DeviceEventEmitter.addListener("STOPSONG", data =&gt; {
        this._handleStopSong();
        console.log("New Event is registered At Listeners STOPSONG");
      }) 
  </code></pre>
  
  <p>According the some article on Medium: </p>
  
  <p>React Native no longer include the Node Standard Library. However, there are standalone modules which have reimplemented the EventEmitter API.</p>
  
  <p>While looking at the <code>NativeEventEmitter.js</code> Abstract base class, I can see this at the constructor. </p>
  
  <pre><code>const EventEmitter = require('../vendor/emitter/EventEmitter');
  const Platform = require('../Utilities/Platform');
  const RCTDeviceEventEmitter = require('./RCTDeviceEventEmitter');
  
  const invariant = require('invariant');
  
  ...
  
  class NativeEventEmitter extends EventEmitter {
    _nativeModule: ?NativeModule;
  
    constructor(nativeModule: ?NativeModule) {
      super(RCTDeviceEventEmitter.sharedSubscriber);
      if (Platform.OS === 'ios') {
        invariant(nativeModule, 'Native module cannot be null.'); &lt;== This where it crashes
        this._nativeModule = nativeModule;
      }
    }
  </code></pre>
  
  <p>Update : </p>
  
  <p>I have created a snack with two component that reproduce what I am trying to achieve : </p>
  
  <p><a href="https://snack.expo.io/@git/github.com/oflarcade/customEventsExpo" rel="nofollow noreferrer">https://snack.expo.io/@git/github.com/oflarcade/customEventsExpo</a></p>
  
  <p>on Android it is working fine / on IOS : </p>
  
  <p><a href="https://i.stack.imgur.com/zl3kK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zl3kK.png" alt="enter image description here"></a></p>