You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So i was working on this app, and everything worked as expected.
At one moment in time i implemented a Table with a button for the refresh data from the API, that looks like this.
When i click the button the refetchLeadsActive is a function that mutates the key, isLoading parameter from SWR always was set with isLoading as true, so the Table will show a Spin Loading Icon, but suddenly now isLoading is always false, the only time that isLoading is true is when i manually refrtesh the page so the Request is made by the first time, im stuck because no error or warning is shown on my console.
Code of hook:
export function useGetLeadsActive() {
const keyCache = `${endpoints.key}${endpoints['active']}/leads/active`;
const url = endpoints.key + endpoints['active'];
const { data, isLoading, error, isValidating } = useSWR(
keyCache,
() => fetcherPost([url, leadsStatus['active']], { company_id: Cookies.get('companySelected') }),
{
revalidateIfStale: false,
revalidateOnFocus: false,
revalidateOnReconnect: true
}
);
console.log("SWR LeadsActive Data:", data);
console.log("SWR LeadsActive Loading:", isLoading);
console.log("SWR LeadsActive Error:", error);
console.log("SWR LeadsActive Validating:", isValidating);
const refetchLeadsActive = async () => {
//when i mutate isLoading is always false, but in the past is set to true
await mutate(keyCache);
};
return {
leadsActiveFilter: data?.data?.items || [],
leadsActiveFilterLoading: isLoading,
leadsActiveFilterError: error,
leadsActiveFilterValidating: isValidating,
leadsActiveFilterEmpty: !isLoading && !data?.data?.items.length,
hasleadsActiveFilter: !isLoading && data?.data?.items.length,
refetchLeadsActive, // Expose the refetch function
};
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone,
So i was working on this app, and everything worked as expected.
At one moment in time i implemented a Table with a button for the refresh data from the API, that looks like this.
When i click the button the refetchLeadsActive is a function that mutates the key, isLoading parameter from SWR always was set with isLoading as true, so the Table will show a Spin Loading Icon, but suddenly now isLoading is always false, the only time that isLoading is true is when i manually refrtesh the page so the Request is made by the first time, im stuck because no error or warning is shown on my console.
Code of hook:
Any idea?
Beta Was this translation helpful? Give feedback.
All reactions