Skip to content

Commit

Permalink
fix(tree): Avoid casting the props
Browse files Browse the repository at this point in the history
  • Loading branch information
fhlavac committed Sep 11, 2024
1 parent a3b5b7f commit a7db24b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/module/src/DataViewTable/DataViewTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ export const isDataViewTrObject = (value: DataViewTr): value is { row: DataViewT
// Tree table typings
export interface DataViewTrTree extends DataViewTrObject { id: string, children?: DataViewTrTree[] }

export type DataViewTableProps = DataViewTableBasicProps | DataViewTableTreeProps;
export type DataViewTableProps =
| ({
isTreeTable: true;
} & DataViewTableTreeProps)
| ({
isTreeTable?: false;
} & DataViewTableBasicProps);

export const DataViewTable: React.FC<DataViewTableProps> = ({ isTreeTable, ...props }: DataViewTableProps) => (
isTreeTable ? (<DataViewTableTree {...(props as DataViewTableTreeProps)} />) : (<DataViewTableBasic {...(props as DataViewTableBasicProps)}/>)
export const DataViewTable: React.FC<DataViewTableProps> = (props) => (
props.isTreeTable ? <DataViewTableTree {...props} /> : <DataViewTableBasic {...props} />
);

export default DataViewTable;

0 comments on commit a7db24b

Please sign in to comment.