一、安装eslint-plugin-react-hooks: cnpm i -D eslint-plugin-react-hooks 二、配置ESLint: 1.打开项目根目录的package.json 2.把 "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, 改为 "eslintConfig": { "extends": [ "react-app", "react-app/jest" ], "plugins":...
This ESLint plugin enforces theRules of Hooks. It is a part of theHooks APIfor React. Installation Note: If you're using Create React App, please usereact-scripts>= 3 instead of adding it directly. Assuming you already have ESLint installed, run: ...
//Refs使用,绑定dom元素,ref 不能设置在无状态组件上 //不要在 render 或者 render 之前访问 refs import React, { Component } from 'react'; class Refsdemo extends Component { constructor(props) { super(props); this.state={ userInput: '' }; } //双向绑定 handleChange(e) { this.setState({...