Rocket.Chat.ReactNative/app/containers/markdown/TableRow.tsx

28 lines
708 B
TypeScript
Raw Normal View History

import React from 'react';
import { View } from 'react-native';
2019-12-04 16:39:53 +00:00
import { themes } from '../../constants/colors';
import styles from './styles';
interface ITableRow {
children: JSX.Element;
isLastRow: boolean;
theme: string;
}
const TableRow = React.memo(({ isLastRow, children: _children, theme }: ITableRow) => {
2019-12-04 16:39:53 +00:00
const rowStyle = [styles.row, { borderColor: themes[theme].borderColor }];
if (!isLastRow) {
rowStyle.push(styles.rowBottomBorder);
}
const children: any = React.Children.toArray(_children);
children[children.length - 1] = React.cloneElement(children[children.length - 1], {
isLastCell: true
});
return <View style={rowStyle}>{children}</View>;
});
export default TableRow;