title: Detect React/ReactDOM development/production build
body: <p>React development build behaves differently than production build, e.g. error handling.</p>
  
  <p>It can be figured out which one is used from the environment but only in modular environment, <a href="https://unpkg.com/react@16.5.2/index.js" rel="noreferrer">due to how <code>process.env.NODE_ENV</code> is used by React package</a>:</p>
  
  <pre><code>if (process.env.NODE_ENV === 'production') {
    module.exports = require('./cjs/react.production.min.js');
  } else {
    module.exports = require('./cjs/react.development.js');
  }
  </code></pre>
  
  <p>The case when <code>process.env</code> may be inapplicable is React used globally as UMD module, <code>window.React</code> and <code>window.ReactDOM</code>:</p>
  
  <pre><code>&lt;script src="some-unknown-react-version.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  React // is it in production mode?
  &lt;/script&gt;
  </code></pre>
  
  <p>Possible uses are:</p>
  
  <ul>
  <li><p>a component that can work in modular and global environments (published as UMD) and renders differently in production</p></li>
  <li><p>browser extension or user script where build/production mode is detected from <code>React</code> or <code>ReactDOM</code> object</p></li>
  </ul>
  
  <p>How can React development/production build be accurately detected at runtime without resorting to the environment?</p>
  
  <p>I'm looking for reliable and clean solution that would be applicable to React 15 and React 16 if possible.</p>
  
  <p><em>This is not a duplicate of similar questions because existing answers  address the problem through <code>process.env</code>.</em></p>