refactor table

This commit is contained in:
Eduard Heimbuch
2019-12-02 13:58:56 +01:00
parent dc169ecff9
commit 52057abef5
6 changed files with 92 additions and 41 deletions

View File

@@ -2,11 +2,17 @@ import React, { FC, ReactNode } from "react";
import { ColumnProps } from "./types";
type Props = ColumnProps & {
children: (row: any) => ReactNode;
children: (row: any, columnIndex: number) => ReactNode;
};
const Column: FC<Props> = ({ row, children }) => {
return <>{children(row)}</>;
const Column: FC<Props> = ({ row, columnIndex, children }) => {
if (row === undefined) {
throw new Error("missing row, use column only as child of Table");
}
if (columnIndex === undefined) {
throw new Error("missing row, use column only as child of Table");
}
return <>{children(row, columnIndex)}</>;
};
export default Column;