title: Reactjs: document is not defined
body: <p>I have a pretty simple react project setup:</p>
  
  <pre><code>├── app.js
  ├── components
  │   ├── MainWrapper.js
  │   └── html.js
  ├── package.json
  └── server.js
  </code></pre>
  
  <p>The application is started by:</p>
  
  <pre><code>node server.js
  </code></pre>
  
  <p>Which uses the express server and renders markup for an HtmlComponent in html.js:</p>
  
  <pre><code>import React from 'react';
  import MainWrapper from './MainWrapper.js'
  
  class HtmlComponent extends React.Component {
      render() {
          return (
              &lt;html&gt;
                  &lt;head&gt;
                      &lt;meta charSet="utf-8" /&gt;
                      &lt;title&gt;My Awesome Site&lt;/title&gt;
                      &lt;meta name="viewport" content="width=device-width, user-scalable=no" /&gt;
                      &lt;link rel="stylesheet" href="awesome.css" /&gt;
                  &lt;/head&gt;
                  &lt;body&gt;
                      &lt;div id="root"&gt;&lt;/div&gt;
                  &lt;/body&gt;
              &lt;/html&gt;
          )
      }
  }
  
  export default HtmlComponent;
  </code></pre>
  
  <p>The goal is to create a Wrapper that will fill the 'root' div.  It's very simple right now:</p>
  
  <p>MainWrapper.js:</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  
  var MainWrapper = React.createClass ({
      render: function() {
          return (
              &lt;button&gt;go&lt;/button&gt;
          )
      }
  });
  
  React.render(&lt;MainWrapper /&gt;, document.getElementById("root"));
  </code></pre>
  
  <p>When I run node server.js there's an exception:</p>
  
  <pre><code>/Users/me/Desktop/Simple/components/MainWrapper.js:36
  _react2['default'].render(_react2['default'].createElement(MainWrapper, null), document.getElementById("root"));
                                                                                 ^
  
  ReferenceError: document is not defined
      at Object.&lt;anonymous&gt; (/Users/me/Desktop/Simple/components/MainWrapper.js:27:31)
      at Module._compile (module.js:425:26)
      at normalLoader (/Users/me/Desktop/Simple/node_modules/babel-core/lib/api/register/node.js:199:5)
      at Object.require.extensions.(anonymous function) [as .js] (/Users/me/Desktop/Simple/node_modules/babel-core/lib/api/register/node.js:216:7)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:311:12)
      at Module.require (module.js:366:17)
      at require (module.js:385:17)
      at Object.&lt;anonymous&gt; (/Users/me/Desktop/Simple/components/Html.js:5:26)
      at Module._compile (module.js:425:26)
  </code></pre>
  
  <p>I do not understand why document is not defined.  It seems it's simple javascript.</p>