useGetOneDeleted
This hook calls dataProvider.getOneDeleted() when the component mounts. It queries the data provider for a single deleted record, based on its id.
const { data, isPending, error, refetch } = useGetOne(
{ id, meta },
options
);
The meta argument is optional. It can be anything you want to pass to the data provider, e.g. a list of fields to show in the result.
The options parameter is optional, and is passed to react-queryβs useQuery hook. Check react-queryβs useQuery hook documentation for details on all available option.
The react-query query key for this hook is ['getOneDeleted', { id: String(id), meta }].
Usage
Call useGetOneDeleted in a component to query the data provider for a single deleted record, based on its id.
import { useGetOneDeleted } from '@react-admin/ra-soft-delete';
const DeletedUser = ({ deletedUserId }) => {
const { data: deletedUser, isPending, error } = useGetOneDeleted({ id: deletedUserId });
if (isPending) { return <Loading />; }
if (error) { return <p>ERROR</p>; }
return <div>User {deletedUser.data.username} (deleted by {deletedUser.deleted_by})</div>;
};
TypeScript
The useGetOneDeleted hook accepts a generic parameter for the record type:
import { useGetOneDeleted } from '@react-admin/ra-soft-delete';
const DeletedUser = ({ deletedUserId }) => {
const { data: deletedUser, isPending, error } = useGetOneDeleted<User>({ id: deletedUserId });
if (isPending) { return <Loading />; }
if (error) { return <p>ERROR</p>; }
// TypeScript knows that deletedUser.data is of type User
return <div>User {deletedUser.data.username} (deleted by {deletedUser.deleted_by})</div>;
};
