The hook which allows you to use ActionJSON to perform actual actions on the backend. Base on the action type and parameters (like ActionJSON.guard) it behaves differently.
Usage
import { useAction } from 'admin-bro'
import { Button } from '@admin-bro/design-system'
const myComponent = ({ action }) => {
const { href, handleClick } = useAction(action, {
resourceId, recordId, recordIds,
}, actionPerformed)
return (
<Button as="a" onClick={handleClick} href={href}>Click this action</Button>
)
}
- New:
- In version 3.3
View Source admin-bro/src/frontend/hooks/use-action/use-action.ts, line 18
Type Definitions
object
# UseActionResult
Result of the useAction.
Properties:
Name | Type | Description |
---|---|---|
href |
string | null | Href to an action. When null it means that action doesn't have neither component nor action, handler |
callApi |
UseActionResultCallApi.<K> | function which will call the API |
handleClick |
function | ready handleClick handler |