title: nextjs complains about read property of undefined during build
body: <p>I am creating comment component using Nextjs for server side rendering. everything works fine in dev mode but when I try to build the optimized production, next js complains about </p>
  
  <pre><code>Cannot read property 'byname' of undefined
  </code></pre>
  
  <p>this is my component: </p>
  
  <pre><code>import React from 'react'
  import moment from 'moment-timezone'
  
  export default function Comment({comment}) {
      return (
          &lt;div&gt;
              &lt;div&gt;
                  &lt;span&gt;{comment.byName}&lt;/span&gt;
                  &lt;span&gt; {moment(new Date(comment.createdOn)).format('ll')}&lt;/span&gt;
              &lt;/div&gt;
              {comment.comment}
          &lt;/div&gt;
      );
  }
  </code></pre>
  
  <p>and this is my scripts in package.json </p>
  
  <pre><code>"scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start"
  }, 
  </code></pre>
  
  <p>this is the error I get </p>
  
  <pre><code>    &gt; next build
  
      info  - Loaded env from /Users/aliemami/coco-project/coco/.env
      Creating an optimized production build
  
      Compiled successfully.
  
      Automatically optimizing pages .
      Error occurred prerendering page "/community/Comment". Read more: https://err.sh/next.js/prerender-error
      TypeError: Cannot read property 'byname' of undefined,
  </code></pre>
  
  <p>I kind of understanding what's going on, probably Nexjs is trying to create a static page from this but cannot because of the variable which is passed to the component, how can I tell nextjs that to create the component on each call? what's the most efficient solution? and how is it that Next can deal with this during development and not production? </p>