Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 635 Bytes

useUnselect.md

File metadata and controls

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

useUnselect

This hook returns a function that unselects lines in the current <Datagrid> 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>
    );
};