title: How to call minimize() and focus() in a React component?
body: <p>I have an Electron example application that minimizes and maximizes the application window, and I would like to do the same in a React application. But how do I get the reference to the main application window in my React component?</p>
  
  <p>My main.js program contains:</p>
  
  <pre><code>const electron = require('electron');
  const {BrowserWindow} = electron;
  ...
  function createWindow() {
      // Create the browser window.
      mainWindow = new BrowserWindow({ width: 500, height: 300, 
                                frame: false, resizable: false });
      global.mainWindow = mainWindow;
      ...
  }
  </code></pre>
  
  <p>In the Electron example, my app/index.js file contains:</p>
  
  <pre><code>var remote = require('electron').remote;
  ...
  remote.getGlobal("mainWindow").minimize();
  </code></pre>
  
  <p>In my React example, my app/app.js file contains:</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import AppContainer from './containers/app.container'
  
  var remote = require('electron').remote;
  </code></pre>
  
  <p>However when running watch I get this error message:</p>
  
  <pre><code>npm run-script watch
  
  &gt; mydemo@1.0.0 watch /home/myname/nodejs/mydemo
  &gt; watchify app/app.js -t babelify -o public/js/bundle.js --debug --verbose
  
  Error: Cannot find module 'electron' from '/home/myname/nodejs/mydemo/app'
  </code></pre>
  
  <p>My questions:</p>
  
  <ul>
  <li>how do I reference the "remote" from inside a React component?</li>
  <li>is there another way of referencing the main application window?</li>
  </ul>