I am using react-table and try to make a single row selectable.
That is my table definition:
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
selectedFlatRows,
state: {selectedRowIds}
} = useTable({
columns: projectColumns,
data,
stateReducer: (newState, action) => {
if (action.type === "toggleRowSelected") {
newState.selectedRowIds = {
[action.id]: true
}
}
return newState;
},
},
useRowSelect,
(hooks) => {
hooks.visibleColumns.push((projectColumns) => [
{
id: "selection",
Header: ({getToggleRowSelectedProps}) => (
<div></div>
),
Cell: ({row}) => (
<div>
<IndeterminateCheckbox {...row.getToggleRowSelectedProps()} />
</div>
),
},
...projectColumns,
]);
}
);
But with that I get an error on the row variable:
Binding element 'row' implicitly has an 'any' type
With the IndertimateCheckbox I have similar problems the type
const IndeterminateCheckbox = React.forwardRef(
({ indeterminate, ...rest }, ref) => {
const defaultRef = React.useRef()
const resolvedRef = ref || defaultRef
React.useEffect(() => {
resolvedRef.current.indeterminate = indeterminate
}, [resolvedRef, indeterminate])
return (
<>
<input type="checkbox" ref={resolvedRef} {...rest} />
</>
)
}
)
Here I get the error:
Property 'indeterminate' does not exist on type '{ children?: ReactNode; }'.
How to resolve this issues?