useSubmission
The state of the latest submission of a server function (or of any submission when called without one).
The state of the latest submission of a server function (or of any submission when called without one).
It is reactive: a component that reads status or result updates when the submission changes. A
submission starts with useSubmit(), a <Form> or a fetcher.
Import#
ts
import { useSubmission } from "@shadow-js/dusk/client";
Signature#
ts
function useSubmission<Input = unknown, Output = unknown>(
target?: StubTarget,
): SubmissionView<Input, Output>
Parameters#
| Name | Description |
|---|---|
target |
The server function (its stub), or a key. Omit it for the newest submission of any key. |
Returns#
A view: status (idle, pending, success, error), pending, input, result,
failed, error, id, clear() and retry().
Examples#
ts
const last = useSubmission(saveNote);
<p>{last.pending ? "Saving" : last.status}</p>