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

前端 未结 30 1681
孤城傲影
孤城傲影 2020-11-22 06:53

I am getting this error:

Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/funct

30条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 07:46

    Just as a quick addition to this. I was having the same problem and while Webpack was compiling my tests and the application was running fine. When I was importing my component into the test file I was using the incorrect case on one of the imports and that was causing the same error.

    import myComponent from '../../src/components/myComponent'
    

    Should have been

    import myComponent from '../../src/components/MyComponent'
    

    Note that the import name myComponent depends on the name of the export inside the MyComponent file.

提交回复
热议问题