next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Uncaught (in promise) TypeError: Cannot read property 'join' of undefined

Open sashberd opened this issue 7 years ago • 12 comments

Hey guys

After update to latest nextjs version I started to get strange error message in console, which was not before: screen shot 2019-02-21 at 16 03 07

My next version is 8.0.1 I use react v16.8.2 on MacOS

Thanks for help

sashberd avatar Feb 21 '19 14:02 sashberd

  updateTitle (component) {
    let title = ''
    if (component) {
      const { children } = component.props
      title = typeof children === 'string' ? children : children.join('')
    }
    if (title !== document.title) document.title = title
  }

Sounds like you have a <title></title> or <title /> somewhere, can you provide a reproduction. Please follow the issue template in the future.

timneutkens avatar Feb 21 '19 14:02 timneutkens

@timneutkens Thanks My problem was that in some way my title was undefined in props, thus next code solve this errors. {title && <title key={key}>{title}</title>}

sashberd avatar Feb 21 '19 14:02 sashberd

I am having the same error and to fix it it's enough to replace

<title>{ this.props.title }</title>

with

<title>{ this.props.title || '' }</title>

Nevertheless, it's a shame that library can't handle "undefined" properly. Especially, considering that it's not an actual variable, but a piece of HTML. HTML is not supposed to raise exceptions.

artemiusgreat avatar Sep 28 '19 22:09 artemiusgreat

Had this issue too because of:

export default function HomePage() {
  return (
    <>
      <Head>
        <title></title>
      </Head>
    </>
  );
}

(empty tag)</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/123822?v=4" alt="vvo avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Mar 10 '20 10:03 </span> <a class="owner-name" href="http://gitmemories.com/vvo"> vvo </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>This issue is still occurring. In my case the data is loaded in asynchronously, so it's undefined until the request returns.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/1710493?v=4" alt="kmturley avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 15 '20 03:08 </span> <a class="owner-name" href="http://gitmemories.com/kmturley"> kmturley </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>I still see the error, running next 9.5.3 installed from npm. What should I do to fix it?</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/33988130?u=2aab12eea72cf2677e553284b56c12dcb510d4ad&v=4" alt="cguidog avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Oct 06 '20 13:10 </span> <a class="owner-name" href="http://gitmemories.com/cguidog"> cguidog </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Hi @cguidog, this is fixed in the latest canary of Next.js <code>v9.5.4-canary.23</code> please upgrade to that version and give it a try!</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/22380829?v=4" alt="ijjk avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Oct 06 '20 14:10 </span> <a class="owner-name" href="http://gitmemories.com/ijjk"> ijjk </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Thanks @ijjk I updated to the indicated version, the error went away, but now the title appears only when the page is loading and then goes away. This is the code I have: <code><title dangerouslySetInnerHTML={{ __html: post.title }} /></code></p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/33988130?u=2aab12eea72cf2677e553284b56c12dcb510d4ad&v=4" alt="cguidog avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Oct 06 '20 15:10 </span> <a class="owner-name" href="http://gitmemories.com/cguidog"> cguidog </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <blockquote> <p>Thanks @ijjk I updated to the indicated version, the error went away, but now the title appears only when the page is loading and then goes away. This is the code I have: <code><title dangerouslySetInnerHTML={{ __html: post.title }} /></code></p> </blockquote> <p>I am facing the same problem. This issue should be reopened.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/3524016?u=8b8f0378c2b49d5aa7d1dcd904a57e2861d422f4&v=4" alt="ducdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Oct 14 '20 17:10 </span> <a class="owner-name" href="http://gitmemories.com/ducdev"> ducdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>I'm facing same issue. This is what I'm doing in the layout component. Some of the connecting pages set their own meta tags and when that happens, I don't pass the title and description properties to the Layout component</p> <pre><code><Head> {title && <title>{title}</title>} {description && <meta name="description" content={description ? description : `${title} - someOtherText`} /> } <meta name="keywords" content={keywords ? keywords : ' ' } /> {title && <meta name="twitter:title" content={url} />} {description && title && <meta name="twitter:description" content={description ? description : `${title} - someOtherText`} />} <meta name="twitter:site" content="summary_large_image" /> {title && <meta property="og:title" content={title} />} {description && title && <meta property="og:description" content={description ? description : `${title} - someOtherText`} />} <meta property="og:site_name" content={url} /> <meta property="og:type" content={type ? type : 'website'} /> <meta property="og:url" content={url} /> <link rel="canonical" href={url} /> </Head> </code></pre> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/17595758?u=a199dece30ecfb8d4ac66f47bb7af403d788ebd2&v=4" alt="MalvinJay avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Dec 17 '20 13:12 </span> <a class="owner-name" href="http://gitmemories.com/MalvinJay"> MalvinJay </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <blockquote> <p>I'm facing same issue. This is what I'm doing in the layout component. Some of the connecting pages set their own meta tags and when that happens, I don't pass the title and description properties to the Layout component</p> <pre><code><Head> {title && <title>{title}</title>} {description && <meta name="description" content={description ? description : `${title} - someOtherText`} /> } <meta name="keywords" content={keywords ? keywords : ' ' } /> {title && <meta name="twitter:title" content={url} />} {description && title && <meta name="twitter:description" content={description ? description : `${title} - someOtherText`} />} <meta name="twitter:site" content="summary_large_image" /> {title && <meta property="og:title" content={title} />} {description && title && <meta property="og:description" content={description ? description : `${title} - someOtherText`} />} <meta property="og:site_name" content={url} /> <meta property="og:type" content={type ? type : 'website'} /> <meta property="og:url" content={url} /> <link rel="canonical" href={url} /> </Head> </code></pre> </blockquote> <p>Concluded too soon, after upgrading next from 9.4 to ^10.0.3, the issue was resolved like magic</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/17595758?u=a199dece30ecfb8d4ac66f47bb7af403d788ebd2&v=4" alt="MalvinJay avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Dec 17 '20 17:12 </span> <a class="owner-name" href="http://gitmemories.com/MalvinJay"> MalvinJay </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/18369201?v=4" alt="balazsorban44 avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Jan 29 '22 00:01 </span> <a class="owner-name" href="http://gitmemories.com/balazsorban44"> balazsorban44 </a> </div> </div> <div class="clear-both"></div> </div> </section> </div> </div> </div> <aside class="detail-info-box"> <h3 class="title pkg-infobox-metadata">Labels</h3> <script type="text/javascript"> atOptions = { 'key' : '6ca19c2b16e3f20a28885886ef99a68e', 'format' : 'iframe', 'height' : 250, 'width' : 300, 'params' : {} }; </script> <script type="text/javascript" src="https://www.highperformanceformat.com/6ca19c2b16e3f20a28885886ef99a68e/invoke.js" ></script> <h3 class="title">Owner</h3> <div class="owner-info flex-items-center d-flex"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/11975561?v=4" alt="sashberd avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <a class="owner-name" href="http://gitmemories.com/sashberd"> sashberd </a> </div> <hr class="color1"> <h3>Other Repo Issues</h3> <div class="packages"> </div> <div style="clear: both"></div> </aside> </div> </div> </main> <footer class="site-footer"> <span>© 2022 Git Memory </span> <a class="link sep" href="http://gitmemories.com/privacy-policy">Policy</a> <a class="link sep" href="http://gitmemories.com/terms">Terms </a> <a class="link sep" href="http://gitmemories.com/contact">Contact </a> <a class="link sep" href="https://exchangetuts.com">Exchangetuts </a> <a class="link sep" href="https://onltools.com/">Onltools </a> <a class="link sep" href="https://serveraide.com/">Serveraide </a> </footer> <script src="http://gitmemories.com/js/app.js?id=a1337f444c840fae34ad"></script> </body> </html>