一些eslint的報紅及解決


1、iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.eslintno-restricted-syntax

原因是使用了for infor of循環,替換為forEach/map循環即可解決。

 

2、React Hook useEffect has a missing dependency: 'queryList'. Either include it or remove the dependency array.eslintreact-hooks/exhaustive-deps

原因是缺少依賴項,但有時我們並不需要寫依賴項,加一句:// eslint-disable-next-line react-hooks/exhaustive-deps即可解決。

 

3、Assignment to property of function parameter 'item'.eslintno-param-reassign

 

原因是循環中不允許直接修改每一項,不能直接對其做增加、刪除、修改操作。新建一個對象,在新的對象上做操作就好。如下圖:

 


免責聲明!

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



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