Home > @activeviam/activeui-sdk > useActions
useActions() function
A React hook that provides an array of actions properties.
Signature:
export declare function useActions(props: UseActionsOptions): ActionProperties[];
Parameters
Parameter | Type | Description |
---|---|---|
props | UseActionsOptions |
Returns:
Remarks
Only the properties of those of the input actions
which are available (in the sense of the action plugin) are passed down. For a given action, these properties can be seen as the corresponding plugin methods curried with the payload
argument, where the payload
holds the widgetApi
passed as a prop but no further context.
Example
Custom buttons to trigger ActiveUI SDK's core undo
and redo
actions.
import Button from 'antd/lib/button';
function UndoRedoButtons() {
const actionsProperties = useActions({
widgetApi,
actions: ['undo', 'redo'],
});
return (
<Button.Group>
{actionsProperties.map(({isDisabled, caption, execute, Icon, key}) => (
<Button disabled={isDisabled} onClick={execute} key={key}>
<Icon />
{caption}
</Button>
))}
</Button.Group>
);
}