Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
See original GitHub issueMy project has products so I have a subfolder in pages
for example:
/pages/produkte/myproduct.js
I am using an HOC - Produkte.js
. This is the root component of every product and I am passing values via props to render it.
-
Trying to set
<NextSeo/>
tomyproduct.js
changes will not apply and the title is left default. -
Trying to set
<NextSeo/>
inProdukte.js
and passing props frommyproduct.js
will throw an error.
Invariant Violation: 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.
myproduct.js
render() {
return (
<Produkt
images={ImgArray}
headline={"TestProduct TestProduct"}
subHeadline={"TestProduct TestProduct | TestProduct"}
bulletPoints={BulletPoints}
reviews={Reviews}
price={"11,90"}
sales={"4623"}
>
<NextSeo config={SeoConfig} />
<ProductJsonLd
productName="TestProduct"
description={"TestProduct - TestProduct | TestProduct"}
brand="TestProduct"
aggregateRating={{
ratingValue: "4.7",
reviewCount: "215"
}}
/>
</Produkt>
);
}
EDIT:
Removed <ProductJsonLd/>
and can verify that the error is coming from <NextSeo/>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Invariant Violation: Element type is invalid: expected a string ...
createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Read more >(React) Element type is invalid, expected a string (for built in ...
To solve the error "Element type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got",...
Read more >Element type is invalid: expected a string (for built-in ... - GitHub
The app breaks and gives this error message: Element type is invalid: expected a string (for built-in components) or a class/function (for ......
Read more >Element type is invalid: expected a string (for ... - OneCompiler
Element type is invalid : expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Read more >Element type is invalid: expected a string (for built-in ... - Reddit
Getting Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@garmeeh & @lenchik-ponchik your solutions are working.
Please consider to update the readme file. The problem was
import NextSeo, { ProductJsonLd } from "next-seo";
<NextSeo />
must be the very first entry in a Child ComponentCould you try this: