4
I’m getting the following warning when using the hook useEffect
:
React Hook useEffect has a Missing dependency: 'connect'. Either include it or remove the dependency array React-Hooks/exhaustive-deps.
I looked at some tutorials on the internet, but I couldn’t find any way out that worked. What am I doing wrong? Follow the problematic code:
const Grafico = (props) => {
const [estoqueReal, setEstoqueReal] = useState([]);
const [estoquePrevisto, setEstoquePrevisto] = useState([]);
const [data, setData] = useState([]);
async function conectar() {
const resposta = await ObterEstoque(props);
setEstoqueReal(resposta[0])
setEstoquePrevisto(resposta[1])
setData(resposta[2])
}
useEffect(() => {
conectar()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (...);