Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

425 B
Raw Blame
import type { RowSelectionState } from "@tanstack/react-table";
import { useMemo, useState } from "react";

export function useEditingTableRowSelection() {
  const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
  const selectedRowIndices = useMemo(
    () => Object.keys(rowSelection).map(Number),
    [rowSelection],
  );

  return {
    rowSelection,
    selectedRowIndices,
    setRowSelection,
  };
}