Uncaught Error: Element type is invalid: expected a string (for built-in components)

前端 未结 2 1542
梦谈多话
梦谈多话 2021-01-23 11:04
I am getting this error. I have defined all components in index.js and I am using react-dom.

Webpacker itself is compiling with no err

相关标签:
2条回答
  • This error is most likely caused because of your import statement. First this is weird import { App } from './components/CustomerSearch'; because here what i expect is that you have a file named CustomSearch.js but from your question it's AppComponent.js so i suggest you change it like this

    import App from './components/AppComponent';
    

    //here the name App doesn't matter as long as you're making a default export which you're doing.

    0 讨论(0)
  • 2021-01-23 11:36

    I'm interpreting the error as saying that maybe you forgot to export your Grid (or maybe your App) component. Is that something you have checked? (In the two files where those components are defined).

    And as abdul said, it's possible the import is in the wrong format. It depends on whether you have exported the components by export or export default.

    For components (or functions, constants etc) that are exported using just export you need to import it with the syntax of import {ComponentName} from .... Else, if they are exported by export default, then they are imported without the curly braces (import ComponentName from ..).

    0 讨论(0)
提交回复
热议问题