title: React and Electron with Draft.js: "Global is not defined"
body: <p>There is a similar question raised here: <a href="https://stackoverflow.com/questions/58936238/uncaught-referenceerror-global-is-not-defined-at-object-node-modules-fbjs-lib">Uncaught ReferenceError: global is not defined at Object../node_modules/fbjs/lib/setImmediate.js</a></p>
  <p>And there are two answers on that question that both seem confident they can solve it. The problem for me is--no explanation of how to implement the answers is given.</p>
  <p>Basically, I have an electron app incorporating React, everything works fine until I try to implement draft.js into the project. I get the following error:</p>
  <pre><code>app.js:19805 Uncaught ReferenceError: global is not defined
  </code></pre>
  <p>The log points me to a line in the babel/webpack-compiled app.js:</p>
  <pre><code>module.exports = global.setImmediate;
  </code></pre>
  <p>The specific thing that causes it is narrowed down to an import statement:</p>
  <pre><code>import {Editor, EditorState} from 'draft-js';
  </code></pre>
  <p>One of the answers in the linked question above says to add a global object on the window:</p>
  <pre><code>(window as any).global = window;
  </code></pre>
  <p>What I can't figure out is... what does that mean? In my main.js file, where I create the window (it's just the one window for the entire app) trying to do this throws an error seemingly no matter where I try to do it, and I can't seem to find any reference to defining 'global' at all. Where am I meant to define 'global'?</p>