2019-11-29 15:57:36 +01:00
|
|
|
import React, { FC, ReactNode } from "react";
|
2019-12-02 15:59:32 +01:00
|
|
|
import { ColumnProps } from "./table";
|
2019-11-29 15:57:36 +01:00
|
|
|
|
|
|
|
|
type Props = ColumnProps & {
|
2019-12-02 13:58:56 +01:00
|
|
|
children: (row: any, columnIndex: number) => ReactNode;
|
2019-11-29 15:57:36 +01:00
|
|
|
};
|
|
|
|
|
|
2019-12-02 13:58:56 +01:00
|
|
|
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)}</>;
|
2019-11-29 15:57:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Column;
|