I am using useEffect for initial data
export const ChannelConfig = (id) => {
const history = useHistory();
const dataUrl = "/channel/"+id;
useEffect(() => {
fetch(dataUrl + "/configure")
.then((resp) => {
if (resp.ok) {
return resp.json();
} else {
handleError(resp, "Server");
}
})
.then((data) => {
setSrcValue(data);
setEditValue(data);
})
}, []);
... ...
function handleError(resp, entity) {
resp.json().then((err) => {
customToast.error(resp.status, err, entity);
if (resp.status === 404) {
history.push("/pages/error-404")
}
});
}
And I got this warning
React Hook useEffect has missing dependencies: 'dataUrl' and 'handleError'. Either include them or remove the dependency array react-hooks/exhaustive-deps
Was I wrong about using useEffect?
And, additionally when I convert "function handleError" to "useCallback", I got missing dependencies warning message about "history" from eslint.