美文网首页
使用react hooks中的setCount时候设置eslin

使用react hooks中的setCount时候设置eslin

作者: 楠楠_c811 | 来源:发表于2020-04-16 11:28 被阅读0次

使用react hooks 时为了避免对新属性不熟悉而犯错,可以安装代码检查工具,命令如下:

  npm i eslint-plugin-react-hooks -D
安装完毕之后,还需要配置,找到package.json文件中的eslintConfig配置 将配置修改如下: image.png
"eslintConfig": {
    "extends": "react-app",
    "plugins":[
      "react-hooks"
    ],
    "rules":{
      "react-hooks/rules-of-hooks":"error"
    }
  },

相关文章

网友评论

      本文标题:使用react hooks中的setCount时候设置eslin

      本文链接:https://www.haomeiwen.com/subject/jktrvhtx.html