is there caching in tRPC
I am trying to fetch new data on state change,
const [categories, setCategories] = useState<categoryType[]>([]); // Initialize with an empty array
useEffect(() => {
const getCategories = async () => {
const categoriesRes = await api.category.getCategories.query()
console.log(categoriesRes); // Use categoriesRes instead of categories
setCategories(categoriesRes);
}
getCategories();
}, [isCategoryClosed, afterFetch, isCategoryOpened]);
even though Im directly logging the response, I see the same categoriesRes being returned, but when the page is refreshed it works as expected by returning the newly added categories. Any idea why this is happening.
const [categories, setCategories] = useState<categoryType[]>([]); // Initialize with an empty array
useEffect(() => {
const getCategories = async () => {
const categoriesRes = await api.category.getCategories.query()
console.log(categoriesRes); // Use categoriesRes instead of categories
setCategories(categoriesRes);
}
getCategories();
}, [isCategoryClosed, afterFetch, isCategoryOpened]);
even though Im directly logging the response, I see the same categoriesRes being returned, but when the page is refreshed it works as expected by returning the newly added categories. Any idea why this is happening.
