组件:
import { useGetUserNotificationsQuery } from "../../../../api_v2/notifications";
const { data: userNotifications, isFetching: loadingNotifications } =
useGetUserNotificationsQuery();
useEffect(() => {
if (userNotifications) {
const unreadedNots = userNotifications?.filter(
(notif) => notif.read === false
);
setUnreadedNotifications(unreadedNots);
}
}, [userNotifications]);
不知道如何设置每24小时轮询一次.我的目标是每24小时刷新一次数据,当组件安装时,我不需要立即获取数据.
我在考虑使用setInterval来实现延迟查询和计时器状态,但不确定这是正确的方式.