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
I work with react query in my app it works fine, few days ago I saw a wierd issue, randomly api get refetched even that before I did not have this issue, when I debug I remark that sometimes after getting notifications all apis within the page get refetched, here is the notification hook :
export const GET_NOTIFICATIONS = "GET_NOTIFICATIONS";
const useNotification = (autoFetch: boolean, query: any) => {
const REFETCH_EACH = 7000;
const { httpClient } = useAxios();
const getNotifications = async () => httpClient?.get<any>(`${NOTIFICATIONS_ENDPOINT}/search`, query);
return useQuery([GET_NOTIFICATIONS], () => getNotifications(), {
enabled: autoFetch && httpClient !== undefined,
/*
* add refetchInterval: <time in ms> to get notif after each 15s for example
*/
refetchInterval: autoFetch ? REFETCH_EACH : false
});
};
and I call notification hook in a global context hook so other components get acces to it :
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
Uh oh!
There was an error while loading. Please reload this page.
-
I work with react query in my app it works fine, few days ago I saw a wierd issue, randomly api get refetched even that before I did not have this issue, when I debug I remark that sometimes after getting notifications all apis within the page get refetched, here is the notification hook :
and I call notification hook in a global context hook so other components get acces to it :
this an api example taht get refetched randomly :
and finally here is the react query global config :
Beta Was this translation helpful? Give feedback.
All reactions