useDeleteAction

Custom hook for deleting objects with dependency checking and confirmation dialogs

Installation

import { useDeleteAction } from 'uxp/components';

Signature

function useDeleteAction(): UseDeleteActionResult

Examples

tsx
const deleteAction = useDeleteAction();

const handleDelete = async () => {
  await deleteAction.delete({
    model: 'Location.Location',
    key: locationKey,
    canHide: true,
    onSuccess: (action) => {
      if (action === 'delete') {
        navigate('/locations');
      } else {
        window.location.reload();
      }
    }
  });
};

Last updated