useBulkDeletePermanentlyWithUndoController
This hook prepares callbacks for a bulk delete permanently button with undo support. It calls dataProvider.hardDeleteMany() in undoable mutation mode, shows a notification, and unselects items from the list.
Warning: The ids here are the IDs of the deleted records, and not the IDs of the original records that have been deleted.
This feature requires a valid Enterprise Edition subscription.
Installation
Section titled “Installation”npm install --save @react-admin/ra-core-ee# oryarn add @react-admin/ra-core-eeimport * as React from 'react';import { useBulkDeletePermanentlyWithUndoController } from '@react-admin/ra-core-ee';
const BulkDeletePermanentlyButton = () => { const { isPending, handleDeleteManyPermanently } = useBulkDeletePermanentlyWithUndoController();
return ( <button type="button" onClick={handleDeleteManyPermanently} disabled={isPending} > Delete selected permanently </button> );};Parameters
Section titled “Parameters”The hook expects an object parameter with the following properties:
ids: The deleted record ids to delete permanently. Defaults touseListContext()selection.mutationOptions:react-querymutation options (supportsmeta).successMessage: A custom notification message key.onClick: A callback called after the mutation is triggered.
TypeScript
Section titled “TypeScript”The useBulkDeletePermanentlyWithUndoController hook accepts a generic parameter for the record type and another for the error type:
useBulkDeletePermanentlyWithUndoController<Product, Error>({ ids: [1, 2, 3], mutationOptions: { onError: error => { // TypeScript knows that error is of type Error }, },});