Error: Invalid hook call. Hooks can only be called inside of the body of a function component.


Error: Invalid hook call. Hooks can only be called inside of the body of a function component.

 

場景:sdk中使用antd,export之后前端工程引入報錯

原因:react沖突

解決:

"peerDependencies": {
    "react": ">=16.9.0",
    "react-dom": ">=16.9.0"
  }

peerDependencies的目的是提示宿主環境去安裝滿足插件peerDependencies所指定依賴的包,然后在插件import或者require所依賴的包的時候,永遠都是引用宿主環境統一安裝的npm包,最終解決插件與所依賴包不一致的問題。

 


免責聲明!

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



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