首页 > 代码库 > ReactJs 报错 Element type is invalid: expected a string (from built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Me`.

ReactJs 报错 Element type is invalid: expected a string (from built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Me`.

  今天在重构一个页面的时候,碰到了一个error,具体的error信息如下图中所示:

  技术分享

  最后经过一番查找定位,终于找到了问题所在,原因就是在父组件引用子组件时多加了一个大括号。

  import {Chart} from ‘Chart‘;

  把{}去掉就可以了。

ReactJs 报错 Element type is invalid: expected a string (from built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Me`.