useFetcher
A fetcher: a mutation or a load that does not navigate and has its own state.
A fetcher: a mutation or a load that does not navigate and has its own state. Keyed: the same key in two components is the same fetcher, so one can show the state another one started. Without a key the fetcher is private to the component.
Import#
ts
import { useFetcher } from "@shadow-js/dusk/client";
Signature#
ts
function useFetcher(key?: string): Fetcher
Parameters#
| Name | Description |
|---|---|
key |
The key of the fetcher. |
Returns#
The fetcher (load, submit, state, data, error, formData).
Examples#
ts
const inbox = useFetcher("inbox");
<button onClick={() => inbox.load("/inbox")}>Refresh</button>