I'm getting this error and i really can t solve it:
src/api/ConnectApi.js
Line 25:8: React Hook useEffect has missing dependencies: 'apiurl', 'dataState', and 'fetch'. Either include them or remove the dependency array. You can also do a functional update 'setDataState(d => ...)' if you only need 'dataState' in the 'setDataState' call react-hooks/exhaustive-deps
Here's what i have in ConnectApi.js
import axios from 'axios';
import { useEffect, useState } from 'react';
const useCollectData = (url) => {
useEffect(() => {
const [fetch, setFetching] = useState({isFetching: false})
const [dataState, setDataState] = useState({data: []});
const [apiurl] = useState(url);
const fetchDataFromApi = async () => {
try{
setFetching({isFetching: true})
const response = await axios.get(apiurl)
setDataState({...dataState, data: response.data});
}
catch (error){
setFetching({...fetch, isFetching: true})
}
};
fetchDataFromApi();
// eslint-disable-next-line react-hooks/exhaustive-deps
},[]);
return [dataState]
};
export default useCollectData
I tried to add apiurl, dataState and fetch to the dependencies array but it won't fix the problem.