const { t } = useTranslation();
- React.useEffect(() => {
- const controller = new AbortController();
+ const fetchEpisodes = React.useCallback((controller, ahead, behind) => {
axios.get(`/api/episodes`, {
signal: controller.signal,
params: {
console.error(e);
}
});
+ }, [setEpisodes]);
+
+ React.useEffect(() => {
+ const controller = new AbortController();
+ fetchEpisodes(controller, ahead, behind);
+ const timer = setInterval(() => {
+ fetchEpisodes(controller, ahead, behind);
+ }, 5 * 60 * 1000);
return () => {
controller.abort();
+ clearInterval(timer);
};
}, [ahead, behind]);