useCreateNotificationNote
Creates a notification note from a typed note body.
When to use it
Successful writes publish a notification-change event so subscribed note and alert queries reload.
Setup
Call it from a client-side React component below OvokProvider so it uses the client configured at that provider boundary.
Hook arguments
The hook takes no configuration arguments. Call mutate(payload) when the user or workflow is ready to run the operation; the payload and result types are shown below.
TypeScript signature
(): OvokMutationState<CreateNotificationNote, NotificationNote>
Mutation state
The operation runs only when you call mutate(payload). The payload type is CreateNotificationNote; the returned promise and data carry NotificationNote.
| Field | Meaning |
|---|---|
data | Latest successful result, or undefined before success. |
loading | Whether the mutation is running. |
error | Normalized Error from the latest failure. |
mutate | Starts the operation, resolves with its result, and rejects on failure. |
reset | Clears mutation data and error state. |
Request behavior
The mutation is explicit: collect and validate the input in your UI, disable repeated submission while loading is true, handle the rejected promise, and render error near the action.
After a successful write, notification and note hooks using this exact OvokClient instance reload. Hooks under another client are not refreshed automatically, even when that client uses the same server and project; share the client instance or call the other hook's reload().
Example
Call the mutation from an event handler and show its error beside the action.
import { useCreateNotificationNote } from '@ovok/core';
type Input = Parameters<ReturnType<typeof useCreateNotificationNote>['mutate']>[0];
export function CreateNotificationNoteExample({ input }: { input: Input }) {
const { mutate, loading, error } = useCreateNotificationNote();
async function submit() {
try { await mutate(input); } catch { /* The hook exposes the error below. */ }
}
return <section>
<button disabled={loading} onClick={() => void submit()}>Submit</button>
{error && <p role="alert">{error.message}</p>}
</section>;
}
Related
- Generated API reference for overloads and exact input and response types.
- React applications for provider setup and application patterns.
- Hook guide index for related hooks.