老师,请问一下,根据官网中的eslint配置Hooks(https://react.docschina.org/docs/hooks-rules.html),在eslint中配置了 “react-hooks/exhaustive-deps”: “warn” // 检查 effect 的依赖,在useEffect使用异步请求获取数据之后,更新state时,就一直提示effect的依赖警告
React Hook useEffect has missing dependencies: ‘getList’ Either include them or remove the dependency array
const getTodoList = (props) =>{
const [list, setList] = React.useState([]);
const {detail} = props;
useEffect(() =>{
getList();
},[detail.id])
}
const getList = async() => {
if(detail.id){
const result = await fetch(/api/getList/${detail.id}
);
setLilt(result.data);
}
}