Skip to main content

useNotificationNotes

Lists notes for a notification target kind and target ID.

When to use it​

The request remains disabled until an ID is supplied; note-change events reload the active target.

Setup​

Call it from a client-side React component below OvokProvider so it uses the client configured at that provider boundary.

Hook arguments​

ArgumentTypeDetails
kindNotificationTargetKindTarget kind identifying which notes to list.
id (optional)stringTarget ID; undefined disables the request.

TypeScript signature​

(kind: NotificationTargetKind, id?: string): OvokRequestState<NotificationNotes>

Request state​

The response payload is NotificationNotes. A successful empty result, a failed request, and a request that has not returned data are distinct states.

FieldMeaning
dataLatest successful response, or undefined before one is available.
loadingWhether the request is in progress.
errorRequest error as an Error, or undefined when no request has failed.
reloadRepeats the request with the current arguments.

Request behavior​

The hook loads when its required inputs are available and reloads when those inputs change. Use reload for an explicit refresh; render loading, error, and successful no-result states separately.

Example​

Handle the hook's loading and error states before rendering the result.

import { useNotificationNotes } from '@ovok/core';

export function NotificationNotesExample({ kind, id }: { kind: Parameters<typeof useNotificationNotes>[0]; id?: Parameters<typeof useNotificationNotes>[1] }) {
const { data, loading, error, reload } = useNotificationNotes(kind, id);
if (loading) return <p>Loading…</p>;
if (error) return <p role="alert">{error.message}</p>;
return <section><button onClick={reload}>Reload</button><pre>{JSON.stringify(data, null, 2)}</pre></section>;
}