Skip to content

Commit a7db24b

Browse files
committed
fix(tree): Avoid casting the props
1 parent a3b5b7f commit a7db24b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/module/src/DataViewTable/DataViewTable.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ export const isDataViewTrObject = (value: DataViewTr): value is { row: DataViewT
2222
// Tree table typings
2323
export interface DataViewTrTree extends DataViewTrObject { id: string, children?: DataViewTrTree[] }
2424

25-
export type DataViewTableProps = DataViewTableBasicProps | DataViewTableTreeProps;
25+
export type DataViewTableProps =
26+
| ({
27+
isTreeTable: true;
28+
} & DataViewTableTreeProps)
29+
| ({
30+
isTreeTable?: false;
31+
} & DataViewTableBasicProps);
2632

27-
export const DataViewTable: React.FC<DataViewTableProps> = ({ isTreeTable, ...props }: DataViewTableProps) => (
28-
isTreeTable ? (<DataViewTableTree {...(props as DataViewTableTreeProps)} />) : (<DataViewTableBasic {...(props as DataViewTableBasicProps)}/>)
33+
export const DataViewTable: React.FC<DataViewTableProps> = (props) => (
34+
props.isTreeTable ? <DataViewTableTree {...props} /> : <DataViewTableBasic {...props} />
2935
);
3036

3137
export default DataViewTable;

0 commit comments

Comments
 (0)