Function: useBoundProp()
API / @xmachines/play-solid / useBoundProp
function useBoundProp<T>(propValue, bindingPath): [T | undefined, (value) => void];Defined in: @json-render/solid
Hook 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/solid";
const Input: ComponentRenderer = (ctx) => { const [value, setValue] = useBoundProp<string>(ctx.props.value, ctx.bindings?.value); return <input value={value ?? ""} onInput={(e) => setValue(e.target.value)} />;};