Function: useBoundProp()
API / @xmachines/play-vue / useBoundProp
function useBoundProp<T>(propValue, bindingPath): [T | undefined, (value) => void];Defined in: @json-render/vue
Composable for two-way bound props. Returns [value, setValue] where:
valueis the already-resolved prop value (passed through from render props)setValuewrites back to the bound state path (no-op if not bound)
Designed to work with the bindings map that the renderer provides when
a prop uses { $bindState: "/path" } or { $bindItem: "field" }.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
propValue | T | undefined |
bindingPath | string | undefined |
Returns
[T | undefined, (value) => void]
Example
import { useBoundProp } from "@json-render/vue";
const Input: ComponentFn<AppCatalog, "Input"> = ({ props, bindings }) => { const [value, setValue] = useBoundProp<string>(props.value as string, bindings?.value); return h("input", { value: value ?? "", onInput: (e) => setValue(e.target.value) });};