云南網(wǎng)站建設(shè)網(wǎng)絡(luò)推廣合作協(xié)議范本
目錄
- 事件起因
- 解決辦法
- 結(jié)束語
事件起因
我的前端react + ant-design-pro項目能正常啟動
但是網(wǎng)頁這邊就是一片空白,然后在瀏覽器的控制臺報錯:
index.js:1 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
解決辦法
導致這個的原因多半都是因為不同版本的react 導致的,我也遇到了,我在多次嘗試后發(fā)現(xiàn)多半是因為我兩個前端項目都同時在本地打開的情況下,webstorm識別到了兩個項目的不同react版本
react 的版本信息位于 package.json里
暫時的解決辦法是將node_modules 給刪除掉,然后重新執(zhí)行 npm install
命令 安裝依賴
結(jié)束語
若是對你有所幫助的話,希望能獲得你的 點贊、評論、收藏,這將是對我很大的鼓勵!!! 這對我真的很重要!!!
蟹蟹?(‘ω’)?