i have this problem:
Line 25:7: React Hook useEffect has missing dependencies: 'getSingleProductData', 'isProductOnSale', and 'productData'. Either include them or remove the dependency array react-hooks/exhaustive-deps
this is the code:
type SingleProductParams = {
s_id:string;
}
type SingleProductProps = RouteComponentProps<SingleProductParams>
const SingleProduct: React.FC<SingleProductProps> = (props) => {
let [productData, setProductData] = useState<Partial<IProdItems>>({});
let [isProductOnSale, setIsProductOnSale] = useState<Sale['onSale']>();
useEffect( () => {
setIsProductOnSale(productData.sale?.onSale);
getSingleProductData();
console.log(productData);
console.log(isProductOnSale);
console.log(props.match.params.s_id);
},[props])
const getSingleProductData = async() => {
let url = URL_API + "/products/single/" + props.match.params.s_id;
let data = await doApiGet(url);
console.log(data);
setProductData(data);
}
how can I fix it? i tried every way from google, that's just doesn't work. but the page all work, i get the data and it's all fine. should i disable the error? I must mention that the console logs inside the useEffect is undefined but the data shown in the site!