ActiveUI

ActiveUI

  • User Guide
  • Developer Documentation

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

ParameterTypeDescription
propsUseActionsOptions

Returns:

ActionProperties[]

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>
  );
}

  • useActions() function
  • Parameters
  • Remarks
  • Example
Copyright © 2023 ActiveViam