记录一下react开发过程中常见报错,警告以及解决的方法

  1. 报错: Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.  

   报这个错的原因是,创建了react组件之后没有使用export default对外暴露就在父组件中应用该,使用export default暴露出去就可以了哦!

        2. 报错: takes an object of state variables to update or a  function which returns an object of state variables

      报错原因:在使用this.setState()方法是传入错误的参数,实力方法setState()方法只接收,需要更新的状态变量的对象,返回值是需更新状态变量的对象的函数和null,如果你闯入的参数都不是object, function ,null那么久会报这个错了

         ......持续更新中

原文地址:https://www.cnblogs.com/zhang-jiao/p/13444859.html