Home > Blockchain >  getting this - Error: Element type is invalid: expected a string (for built-in components)
getting this - Error: Element type is invalid: expected a string (for built-in components)

Time:10-14

getting this error - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. SS- https://cdn.discordapp.com/attachments/767641462179233792/1030163204707455056/unknown.png

so confused right now, I'm just learning react

CodePudding user response:

You have this {Product, FooterBanner, Hero Banner} from '../components'

This is wrong. What you are doing above is trying to import those components from a file called components.

Do this

Import Product from '../components/Product'
Import FooterBanner from '../components/FooterBanner'

Do that for all three of them, and make sure that those individual files have an export default, For example in Product.jsx, make sure the export is export default Product

CodePudding user response:

You use named import when you import 3 components from ../Components folder, so in ../Components/index.js you should properly export 3 components through named export.

If nothing wrong there, and then explore other components in whole project tree related to lines where you use export statement.

  • Related