ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
25 lines (22 loc) • 573 B
text/typescript
import { useCallback } from 'react';
import { useRecordSelection } from './useRecordSelection';
import { Identifier } from '../../types';
/**
* Hook to Unselect the rows of a datagrid
*
* @example
*
* const unselect = useUnselect('posts');
* unselect([123, 456]);
*/
export const useUnselect = (resource?: string) => {
const [, { unselect }] = useRecordSelection(
resource ? { resource } : { disableSyncWithStore: true }
);
return useCallback(
(ids: Identifier[]) => {
unselect(ids);
},
[unselect]
);
};