昨天在项目中,重新封装组件时,引用了原来的一个子组件,但发现子组件在其他页面正常,在新的组件里面就发生保存,

然后把子组件注释,随便显示其div元素也正常,纠结了很久,最后发现引用的方式有问题

子组件创建是用 export class BaseComponent extends Component {  . . .  }

新创建的组件中引用是是使用 import BaseComponent from '../components/BaseComponent', 感觉一切正常,但一直报下面的错误,最后发现引用有问题,

将引用方式调整为 import { BaseComponent } from '../components/BaseComponent' 就不报错了

 

创建组件后,使用 export default ComponentName;  在引用是要使用 import ComponentName from  './ComponentName';

 

 

报错提示信息如下图:

React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

 

React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

 

相关文章:

  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-05-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2021-04-12
  • 2021-05-12
  • 2022-12-23
  • 2021-07-08
相关资源
相似解决方案