Response Hooks
Hooks for reading and writing quiz/survey response variables (answers.* namespace).
Every response variable must be declared in responses in your appfunnel.config.ts before it can be used. Undeclared keys will be ignored.
useResponse<T>(key)
Read/write a single response variable. This is the primary hook for capturing visitor answers.
const [goal, setGoal] = useResponse<string>('goal')
const [interests, setInterests] = useResponse<string[]>('interests')| Return | Type | Description |
|---|---|---|
[0] | T | Current response value |
[1] | (value: T) => void | Setter function |
useResponses()
Returns all response variables as a flat object with the answers. prefix stripped. Only re-renders when an answers.* variable changes.
const responses = useResponses()
// { goal: 'weight_loss', interests: ['yoga', 'running'] }| Return | Type | Description |
|---|---|---|
responses | Record<string, VariableValue> | All response key-value pairs |
Last updated on