Something wrong with my next-seo code, getting Element type is invalid


Following is my next-seo code

import React from 'react';
import { NextSeo, ArticleJsonLd } from 'next-seo';

export default () => (
  <>
    <NextSeo
      title="Simple Usage Example"
      description="A short description goes here."
    />

    <ArticleJsonLd
      url="https://example.com/article"
      title="Article title"
      images={[]}
      datePublished="2019-06-29T08:00:00+08:00"
      dateModified="2019-06-29T09:00:00+08:00"
      authorName="Foo Bar"
      publisherName="Foo Press"
      publisherLogo="https://www.example.com/photos/logo.jpg"
      description="description of this article"
    />

    {/*
        my component code
     */
    }

  </>
);

But I am getting the following error with this

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

1 Answer

5 years ago by

NextSeo is a default export, Following is from their code

export default class NextSeo extends Component<NextSeoProps> { }

So in your code change the following import

~~```javascript
import { NextSeo, ArticleJsonLd } from 'next-seo';


to the following

```javascript
import NextSeo, { ArticleJsonLd } from 'next-seo';
5 years ago by Karthik Divi