Reputation: 47
I'm using useSWRInfinite for notifications scrolling which is inside navbar layout.
When I click a button inside notification I want to route to that page and I update notification as read in database, but the update is not reflected in notifications.
I need to somehow mutate notification list after going to another page.
`function getKey(pageIndex, previousPageData) {
if (previousPageData && !previousPageData.length) {
return null;
}
return `/api/admin/navbar/notifications?page=${pageIndex + 1}&limit=10&filterBy=${filterStatus}`;
}
const { data, size, setSize, isLoading, mutate, } = useSWRInfinite(getKey, fetcher, {});
const router = useRouter();
const navigate = () => {
router.push("/admin/order/" + notification.lookupId);
mutate()
};`
Upvotes: 0
Views: 70