Getting this error in my console. Not sure how to handle them
I am passing in guildId, so im not sure why its logging this error
src/utils/hooks/useFetchGuildBans.tsx
Line 22:6: React Hook useEffect has a missing dependency: 'guildId'. Either include it or remove the dependency array react-hooks/exhaustive-deps
Here is my useFetchGuildBans.tsx
import { useEffect, useState } from 'react';
import { getGuildBans } from '../api';
import { GuildBanType } from '../types';
export function useFetchGuildBans(guildId: string) {
const [bans, setBans] = useState<GuildBanType[]>([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState();
const [updating, setUpdating] = useState(false);
useEffect(() => {
setLoading(true);
getGuildBans(guildId)
.then(({ data }) => {
setBans(data);
})
.catch((err) => {
console.log(err);
setError(err);
})
.finally(() => setLoading(false));
}, [updating]);
return { bans, loading, error, updating, setUpdating };
}
useEffect(() => {
setLoading(true);
getGuildBans(guildId)
.then(({ data }) => {
setBans(data);
})
.catch((err) => {
console.log(err);
setError(err);
})
.finally(() => setLoading(false));
}, [updating, guildId]);
The second parameter of useEffect is called the dependencies array. The error message is saying that guildId is missing from this array.