create sortable table

This commit is contained in:
Eduard Heimbuch
2019-11-29 15:57:36 +01:00
parent d7de7c2f36
commit 14786d7a1a
5 changed files with 130 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import React, { FC } from "react";
import {ColumnProps} from "./types";
type Props = ColumnProps & {
dataKey: string;
};
const TextColumn: FC<Props> = ({ row, dataKey }) => {
return row[dataKey];
};
TextColumn.defaultProps = {
createComparator: (props: Props) => {
return (a: any, b: any) => {
if (a[props.dataKey] < b[props.dataKey]) {
return -1;
} else if (a[props.dataKey] > b[props.dataKey]) {
return 1;
} else {
return 0;
}
};
}
};
export default TextColumn;