首页 > 其他 > 详细

react 项目中的报错,警告总结

时间:2021-07-08 18:20:34      阅读:20      评论:0      收藏:0      [点我收藏+]

1.Nested block is redundant  no-lone-blocks

2.Unexpected string concatenation of literals no-useless-concat

拼接字符串报错 "Unexpected string concatenation"
错误原因:ESLint推荐用ES6方法来拼接字符串,而不能使用加号。
解决办法:拼接字符串使用形如:
`字符串字符串字符串${变量名}字符串字符串字符串${返回字符串的方法}字符串字符串`的写法。

3.series not exists. Legend data should be same with series name or data name.

4.React Hook useEffect has a missing dependency: ‘fetchBusinesses‘. Either include it or remove the dependency array react-hooks/exhaustive-deps

这不是JS / React错误,而是eslint警告。

它告诉你钩子依赖于函数fetchBusinesses,所以你应该把它作为依赖传递。

1.useEffect(() => {

  fetchBusinesses();
}, [fetchBusinesses]);

如果fetchBusinessess在运行中没有组件,那将不会真正改变任何事情,但警告将消失。

2.useEffect(() => { // other code ... // eslint-disable-next-line react-hooks/exhaustive-deps }, [])

参考文章:https://www.soinside.com/question/yyxQ6i8PKsVyaS3teSftxH

5.

 

react 项目中的报错,警告总结

原文:https://www.cnblogs.com/shine1234/p/14985688.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!