Skip to content

Commit

Permalink
fix(findNodeById): use generics
Browse files Browse the repository at this point in the history
  • Loading branch information
rwieruch committed Aug 24, 2022
1 parent ecff581 commit d32b68b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/common/util/tree/findNodeById.ts
@@ -1,15 +1,15 @@
import { TableNode } from '@table-library/react-table-library/types/table';

export const findNodeById = (nodes: TableNode[], id: string): TableNode | null =>
nodes.reduce((acc: TableNode | null, value: TableNode) => {
export const findNodeById = <T extends TableNode>(nodes: T[], id: string): T | null =>
nodes.reduce((acc: T | null, value: T): T | null => {
if (acc) return acc;

if (value.id === id) {
return value;
}

if (value.nodes) {
return findNodeById(value.nodes, id);
return findNodeById(value.nodes, id) as T;
}

return acc;
Expand Down
1 change: 0 additions & 1 deletion src/select/useRowSelect.tsx
Expand Up @@ -40,7 +40,6 @@ const getRowProps = (props: RowProps, features: Features): FeatureProps => {
const theme = `
&.row-select-selected,
&.row-select-single-selected {
color: ${COLORS.FONT_PRIMARY};
font-weight: bold;
background-color: ${COLORS.ROW_SELECTED};
Expand Down

0 comments on commit d32b68b

Please sign in to comment.