I've got a question regarding a missing dependency warning.
I've got a GET request where I'd like to set the catch error state. However when setting the error it asks to add the setError in the dependency list. The dependency should only be the {value}, not the setError right?
useEffect(() => {
if (value.length === 3) {
setLoading(true);
axios
.get(
`https://url.com?search=${value}`
)
.then((res) => setCompanies(res.data.data))
.then(() => setLoading(false))
.catch((err) => {
if (err.response.status === 500) {
setError("something went wrong");
}
});
}
}, [value]);
Warning notification: React Hook useEffect has a missing dependency: 'setError'. Either include it or remove the dependency array.