Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 636 Bytes

File metadata and controls

28 lines (21 loc) · 636 Bytes
layout default
title useUnselect

useUnselect

This hook returns a function that unselects lines in the current <DataTable> that match an array of ids. Pass the name of the resource to the hook as argument.

import { useListContext, useUnselect } from 'react-admin';

const UnselectButton = () => {
    const { resource, selectedIds } = useListContext();
    const unselect = useUnselect(resource);

    const handleClick = () => {
        unselect(selectedIds);
    };

    return (
        <button onClick={handleClick}>
            {`Unselect ${selectedIds.length} records`}
        </button>
    );
};