Skip to content

toolmark-monorepo / @toolmark/react / useFormTool

Function: useFormTool() ​

useFormTool<V>(adapter, opts): void

Defined in: packages/react/src/use-form-tool.ts:64

Registers <name>.fill and <name>.submit for adapter (spec §8.1, §9) while the component is mounted.

Registration happens in an effect, under the current scope. adapter is read through a ref updated on every render, so passing a fresh adapter object each render never forces a re-registration by itself and every call always uses the latest adapter. submitSummary is read the same way. The tools re-register only when name, description, title, sensitive (compared shallowly) or the input/jsonSchema identities change.

Type Parameters ​

V ​

V extends Record<string, unknown>

Parameters ​

adapter ​

FormAdapter<V>

Bridges the form library to the form tools.

opts ​

FormToolOptions<V>

See FormToolOptions.

Returns ​

void