<h2 dir="auto">Describe the bug</h2>
<p dir="auto"><code class="notranslate">yarn dev</code> works fine, but <code class="notranslate">yarn build &amp;&amp; yarn start</code> errors out</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior, please provide code snippets or a repository:</p>
<ol dir="auto">
<li>clone repo, <code class="notranslate">cd examples/with-styletron</code>, <code class="notranslate">yarn install</code></li>
<li><code class="notranslate">yarn build</code></li>
<li><code class="notranslate">yarn start</code></li>
<li>Load <a href="http://localhost:3000" rel="nofollow">http://localhost:3000</a></li>
<li>See error in shell:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; Ready on http://localhost:3000
TypeError: Cannot read property 'renderStyle' of undefined
    at driver (/Users/s/workspace/next.js/examples/with-styletron/node_modules/styletron-standard/dist/index.js:16:20)
    at Object.StyledElement.React.createElement [as children] (/Users/s/workspace/next.js/examples/with-styletron/node_modules/styletron-react/dist/index.js:284:32)
    at a.render (/Users/s/workspace/next.js/examples/with-styletron/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:64)
    at a.read (/Users/s/workspace/next.js/examples/with-styletron/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:58)
    at renderToString (/Users/s/workspace/next.js/examples/with-styletron/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:53:83)
    at render (/Users/s/workspace/next.js/examples/with-styletron/node_modules/next-server/dist/server/render.js:86:16)
    at renderPage (/Users/s/workspace/next.js/examples/with-styletron/node_modules/next-server/dist/server/render.js:211:20)
    at Function.getInitialProps (/Users/s/workspace/next.js/examples/with-styletron/.next/server/static/RUt_NNFZYVNClDESx18vF/pages/_document.js:398:18)
    at Object.loadGetInitialProps (/Users/s/workspace/next.js/examples/with-styletron/node_modules/next-server/dist/lib/utils.js:42:35)
    at Object.renderToHTML (/Users/s/workspace/next.js/examples/with-styletron/node_modules/next-server/dist/server/render.js:218:36)"><pre class="notranslate"><code class="notranslate">&gt; Ready on http://localhost:3000
TypeError: Cannot read property 'renderStyle' of undefined
    at driver (/Users/s/workspace/next.js/examples/with-styletron/node_modules/styletron-standard/dist/index.js:16:20)
    at Object.StyledElement.React.createElement [as children] (/Users/s/workspace/next.js/examples/with-styletron/node_modules/styletron-react/dist/index.js:284:32)
    at a.render (/Users/s/workspace/next.js/examples/with-styletron/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:64)
    at a.read (/Users/s/workspace/next.js/examples/with-styletron/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:58)
    at renderToString (/Users/s/workspace/next.js/examples/with-styletron/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:53:83)
    at render (/Users/s/workspace/next.js/examples/with-styletron/node_modules/next-server/dist/server/render.js:86:16)
    at renderPage (/Users/s/workspace/next.js/examples/with-styletron/node_modules/next-server/dist/server/render.js:211:20)
    at Function.getInitialProps (/Users/s/workspace/next.js/examples/with-styletron/.next/server/static/RUt_NNFZYVNClDESx18vF/pages/_document.js:398:18)
    at Object.loadGetInitialProps (/Users/s/workspace/next.js/examples/with-styletron/node_modules/next-server/dist/lib/utils.js:42:35)
    at Object.renderToHTML (/Users/s/workspace/next.js/examples/with-styletron/node_modules/next-server/dist/server/render.js:218:36)
</code></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">Page should render properly</p>
<h2 dir="auto">Screenshots</h2>
<p dir="auto">If applicable, add screenshots to help explain your problem.</p>
<h2 dir="auto">System information</h2>
<ul dir="auto">
<li>OS: macOS</li>
<li>Browser (if applies) [e.g. chrome, safari]</li>
<li>Version of Next.js: <code class="notranslate">latest</code></li>
</ul>
<h2 dir="auto">Additional context</h2>
<p dir="auto">Add any other context about the problem here.</p>
<h1 dir="auto">Bug report</h1>
<h2 dir="auto">Describe the bug</h2>
<p dir="auto">In Next.js 8.1.0 React Context.Consumer receives value of undefined</p>
<p dir="auto">Only on server side</p>
<p dir="auto">UPDATE: Only in production, not in <code class="notranslate">npm run dev</code></p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Reproduce repository - <a href="https://github.com/zpnester/next-consumer-issue">link</a></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const MyContext = React.createContext();

function Home() {

    return &lt;MyContext.Provider value={{ x: &quot;123&quot; }}&gt;
        &lt;MyContext.Consumer&gt;
            {value =&gt; value.x}
        &lt;/MyContext.Consumer&gt;
    &lt;/MyContext.Provider&gt;
}

export default Home;"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-v">MyContext</span> <span class="pl-c1">=</span> <span class="pl-v">React</span><span class="pl-kos">.</span><span class="pl-en">createContext</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-v">Home</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

    <span class="pl-k">return</span> <span class="pl-c1">&lt;</span><span class="pl-v">MyContext</span><span class="pl-kos">.</span><span class="pl-v">Provider</span> <span class="pl-c1">value</span><span class="pl-c1">=</span><span class="pl-kos">{</span><span class="pl-kos">{</span> <span class="pl-c1">x</span>: <span class="pl-s">"123"</span> <span class="pl-kos">}</span><span class="pl-kos">}</span><span class="pl-c1">&gt;</span>
        <span class="pl-c1">&lt;</span><span class="pl-v">MyContext</span><span class="pl-kos">.</span><span class="pl-v">Consumer</span><span class="pl-c1">&gt;</span>
            <span class="pl-kos">{</span><span class="pl-s1">value</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">value</span><span class="pl-kos">.</span><span class="pl-c1">x</span><span class="pl-kos">}</span>
        <span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-v">MyContext</span><span class="pl-kos">.</span><span class="pl-v">Consumer</span><span class="pl-c1">&gt;</span>
    <span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-v">MyContext</span><span class="pl-kos">.</span><span class="pl-v">Provider</span><span class="pl-c1">&gt;</span>
<span class="pl-kos">}</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-v">Home</span><span class="pl-kos">;</span></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">MyContext.Consumer value should receive object from MyContext.Provider</p>
<h2 dir="auto">System information</h2>
<ul dir="auto">
<li>Version of Next.js: 8.1.0</li>
</ul>
<h2 dir="auto">Additional context</h2>
<p dir="auto">Also an issue for many Antd components</p>