vn-verdnaturachat/app/containers/markdown/TableRow.js

32 lines
751 B
JavaScript
Raw Normal View History

import PropTypes from 'prop-types';
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';
const TableRow = React.memo(({
2019-12-04 16:39:53 +00:00
isLastRow, children: _children, theme
}) => {
2019-12-04 16:39:53 +00:00
const rowStyle = [styles.row, { borderColor: themes[theme].borderColor }];
if (!isLastRow) {
rowStyle.push(styles.rowBottomBorder);
}
const children = React.Children.toArray(_children);
children[children.length - 1] = React.cloneElement(children[children.length - 1], {
isLastCell: true
});
return <View style={rowStyle}>{children}</View>;
});
TableRow.propTypes = {
children: PropTypes.node,
2019-12-04 16:39:53 +00:00
isLastRow: PropTypes.bool,
theme: PropTypes.string
};
export default TableRow;