HI all I recently started using react and I have a simple question, I have this function that is supposed to fetch content and it stores the response in the variable data. after the page load when I console log it I see that the data is being fetched multiple times, when I refresh it it's loading a couple more times again. How do I fix this?
import {useQuery} from "react-query";
import axios from "axios";
const fetchBrands = async () =>{
const res = await axios.get("APIURL");
return res.data;
}
export default function LoadBrands() {
const {data, status} = useQuery('getbrand', fetchBrands);
return(
<>
{status === 'loading' && <div>Loading</div>}
{status === 'error' && <div>Error Loading</div>}
{status === 'success' && <div>YUPP</div>}
{console.log(data)}
</>
)
}