question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to execute 'createElement' on 'Document' | v9.5.4

See original GitHub issue

Bug report

Describe the bug

I ran into this error after updating Next.js to version 9.5.4. The problem is that you cannot use React Components inside Head in _app.js file.

Minimal Example:

const Metadata = () => (
  <>
      <base href="/" />
      <meta name="msapplication-TileColor" content="#000000" />
      {/*...*/}
  </>
)

class NextApp extends App {
  render() {
      return (
          <>
              <Head>
                  <title>Next Bug Report</title>
                  {/*Error*/}
                  <Metadata />
              </Head>
          </>
      )
  }
}

To Reproduce

Just open the dev server

Reproduction repo: next-bug-report

Screenshots

image

System information

  • Version of Next.js: [9.5.4]
  • Version of React/ReactDOM: [16.13.1]
  • Version of Node.js: [14.0.0]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:56
  • Comments:28 (17 by maintainers)

github_iconTop GitHub Comments

35reactions
danvoycecommented, Oct 9, 2020

Also having this issue when trying pass a component into the <Head>

7reactions
alaingogacommented, Oct 14, 2020

@jflayhart in our case we just called a function that returns an array of links to prefetch, preconnect. so:

  <Head>
     <title>Page title</title>
    ... etc
     { getResourceHints() }
  </Head>

instead of:

  <Head>
     <title>Page title</title>
    ... etc
     <ResourceHints />
  </Head>

That fixed our problem on dev build and removed the error on console in production. Maybe that could help, in some cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to execute 'createElement' on 'Document': The tag ...
In my case, I was building my web app and I had created a javaScript file in the IDE IntelliJ. But in the...
Read more >
Failed To Execute 'Createelement' On 'Document': The Tag ...
Failed to execute 'createElement' on 'Document': The tag name provided is not a valid name #197. I'm trying to have reactsvgloader 2.1.0 to...
Read more >
Release Notes - Documentation ・ CoreMedia
Now, a concluding failure message is written to stdout. ... To enable the IPreviewUrlTransformer execution for the external ... createElement('script');.
Read more >
next js sass variables - You.com | The search engine you control.
On Next.js v9.5.4 and later, you should use additionalData . Open side panel ... Unable to override Vuetify 2.1 SASS variables.
Read more >
Failed to execute 'createElement' on 'Document' error message
[This thread is closed.] Hello, while logged into my website, hovering over the “G Site Kit” link in the black WordPress admin bar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found