記錄一下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那么久會報這個錯了

 

         ......持續更新中

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM