Variable Hooks (Advanced)
Low-level hooks for reading and writing any variable by its full namespaced ID. In most cases, prefer the scoped hooks: useResponse, useData, useQueryParam.
useVariable<T>(id)
Read/write any variable by its full namespaced ID.
const [goal, setGoal] = useVariable<string>('answers.goal')
const [isMobile] = useVariable<boolean>('device.isMobile') // system vars are read-only| Return | Type | Description |
|---|---|---|
[0] | T | Current value of the variable |
[1] | (value: T) => void | Setter function (no-op for system variables) |
useVariables()
Returns all variables across every namespace. Re-renders on ANY variable change.
This hook subscribes to every variable update. Prefer scoped hooks like useResponse or useData to avoid unnecessary re-renders.
const variables = useVariables()| Return | Type | Description |
|---|---|---|
variables | Record<string, VariableValue> | Every variable in the store |
Last updated on