Skip to content

useActions

useActions(): (input) => (…args) => void

Defined in: store/StoreProvider.tsx:329

The canonical dispatch API for event handlers. Accepts either a single action tuple or an array of tuples and returns a React event handler that fires them through the shared executor (event placeholders, async, machine actions all flow through unchanged).

const actions = useActions();
// single action — argument is the tuple
<input onChange={actions(['action/save', ['name'], 'event/target.value'])} />
// multiple actions — argument is an array of tuples
<button onClick={actions([
['event/preventDefault'],
['action/async-prevent', 'submit', 'submit'],
])} />

The discriminator is the first element: a string means “single action,” an array means “list of actions.” See ADR 0023.

For state-derived payloads or conditional dispatch, fall back to useDispatch + an inline closure, or register a factory binding.

(input) => (…args) => void