Display a single notification
This component renders a single notification. It's best used to build a custom notification experience if the notification list component isn't suitable. In combination with the notifications REST API to send notifications, and the notifications data JS API to retrieve them, you can build a completely custom notifications experience.
import { Notification } from "@cord-sdk/react";
export const Example = () => {
return (
<Notification notificationId="my-awesome-notification-id" />
);
};
onClick
callback. To do so, you will have to prevent the default navigation that happens when users click on the notification, await
your logic and then resume navigation.import { Notification } from "@cord-sdk/react";
export const Example = () => {
return (
<Notification
notificationId="my-awesome-notification-id"
onClick={(event, { destinationUrl }) => {
// Don't navigate to another page.
event.preventDefault();
// Run any logic you need
myAsyncCallback().then(() => {
// When you're done, resume navigation!
window.location.assign(destinationUrl);
});
}}
/>
);
};
Not finding the answer you need? Ask our Developer Community