使用react hooks 时为了避免对新属性不熟悉而犯错,可以安装代码检查工具,命令如下:
npm i eslint-plugin-react-hooks -D
安装完毕之后,还需要配置,找到package.json文件中的eslintConfig配置


"eslintConfig": {
"extends": "react-app",
"plugins":[
"react-hooks"
],
"rules":{
"react-hooks/rules-of-hooks":"error"
}
},
网友评论