Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Element type is invalid in _document.js #56

Open
mariabarkouzou opened this issue Dec 10, 2021 · 0 comments
Open

Element type is invalid in _document.js #56

mariabarkouzou opened this issue Dec 10, 2021 · 0 comments

Comments

@mariabarkouzou
Copy link

mariabarkouzou commented Dec 10, 2021

I've created the _document.js as suggested in the template but I get this error in the console:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

The code is this:

import React from 'react'
import Document, {Html, Head, Main, NextScript} from 'next/document'
import client from '../client'

export default class MyDocument extends Document {
static async getInitialProps (ctx) {
const initialProps = await Document.getInitialProps(ctx)
return client.fetch('*[_id == "global-config"] {lang}.lang[0]').then(lang => {
return {...initialProps, lang}
})
}

render () {
return (

  <Html lang={this.props.lang || 'en'}>
    <Head />
    <body>
      <Main />
      <NextScript />
    </body>
  </Html>
 
)

}
}

Has anyone had this issue?And if yes , how did you solve it?Thank you in advance!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant