Request keeps polling even with refreshInterval set to 0 #4081
Unanswered
hydrohiester
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was setting refreshInterval with a state variable that polls and when it gets a certain result, it is a dependency in a useEffect that sets the interval to 0. It kept polling even after the interval was set to 0. Then I tested, hard-coding the interval to 0 and it still keeps making requests. Why would this be happening?
const fetcher = async (url: string) => { return fetch(url, { method: "GET", headers: { Authorization:
Bearer ${token}`,},
}).then((res) => res.json());
};
const { data, error } = useSWR(
/api/my/endpoint
,fetcher,
{ refreshInterval: 0 }
);`
Beta Was this translation helpful? Give feedback.
All reactions