Uncaught (in promise) TypeError: Cannot read property 'join' of undefined
Hey guys
After update to latest nextjs version I started to get strange error message in console, which was not before:

My next version is 8.0.1 I use react v16.8.2 on MacOS
Thanks for help
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 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>}
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.
Had this issue too because of:
export default function HomePage() {
return (
<>
<Head>
<title></title>
</Head>
</>
);
}
(empty
This issue is still occurring. In my case the data is loaded in asynchronously, so it's undefined until the request returns.
I still see the error, running next 9.5.3 installed from npm. What should I do to fix it?
Hi @cguidog, this is fixed in the latest canary of Next.js v9.5.4-canary.23 please upgrade to that version and give it a try!
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:
<title dangerouslySetInnerHTML={{ __html: post.title }} />
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:
<title dangerouslySetInnerHTML={{ __html: post.title }} />
I am facing the same problem. This issue should be reopened.
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
<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>
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
<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>
Concluded too soon, after upgrading next from 9.4 to ^10.0.3, the issue was resolved like magic
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.