React项目报错:Element type is invalid: expected a string可能的原因

发布时间 2023-12-01 23:33:06作者: FacingScreen

React项目报错:Element type is invalid: expected a string 

起因:用了屎一样的React Antd组件库,坑太多实在用不下去了,代码不变直接改成Tdesign,于是就开始了解决无穷无尽的报错。。。

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. Check the render method of `Index`.

可能的原因:

  1. 组件名错误,比如MenuItem写成了Menu.item
  2. 还是组件名错误,比如antd里的Sider,Tdegsin里是Aside