useAnswer
function useAnswer<M, R, K>( channel, type, responder, options?): void;Answer asks of one type for as long as this component is mounted.
A hook rather than a bare channel.answer call because a responder is a
subscription: registering one in a render would leave the last unmounted
component answering for the page.
One responder per type per channel — registering a second replaces the first,
which is the same first-wins-then-replace rule answer has in core.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
M extends MessageMap |
R extends Partial<Record<keyof M, unknown>> |
K extends string |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
channel | Channel<M, R> |
type | K |
responder | (payload, meta) => R[K] |
options? | { enabled?: boolean; } |
options.enabled? | boolean |
Returns
Section titled “Returns”void