How to use the notification API to observe notification summary information
This method allows you to observe summary information about the current user's notifications, including live updates.
import { notification } from '@cord-sdk/react';
const summary = notification.useSummary();
import { notification } from '@cord-sdk/react';
const summary = notification.useSummary();
return (
<div>
{!summary && "Loading..."}
{summary && (
<p>Unread notifications: {summary.unread}</p>
)}
</div>
);
The API provides an object which has the following fields:
The hook will initially return undefined
while the data loads from our API. Once it has loaded, your component will re-render and the hook will return an object containing the fields described under "Available Data" above. The component will automatically re-render if any of the data changes, i.e., this data is always "live".
This function takes no arguments.