bee-table/src/TableHeader.js

37 lines
842 B
JavaScript
Raw Normal View History

import React, { Component } from 'react';
import PropTypes from 'prop-types';
2016-12-26 16:52:39 +08:00
import shallowequal from 'shallowequal';
2017-01-11 17:01:50 +08:00
const propTypes = {
clsPrefix: PropTypes.string,
2016-12-26 16:52:39 +08:00
rowStyle: PropTypes.object,
rows: PropTypes.array,
2017-01-11 17:01:50 +08:00
}
class TableHeader extends Component{
constructor(props){
super(props);
}
2016-12-26 16:52:39 +08:00
shouldComponentUpdate(nextProps) {
return !shallowequal(nextProps, this.props);
2017-01-11 17:01:50 +08:00
}
2016-12-26 16:52:39 +08:00
render() {
2017-01-11 17:01:50 +08:00
const { clsPrefix, rowStyle, rows } = this.props;
2016-12-26 16:52:39 +08:00
return (
2017-01-11 17:01:50 +08:00
<thead className={`${clsPrefix}-thead`}>
2016-12-26 16:52:39 +08:00
{
rows.map((row, index) => (
<tr key={index} style={rowStyle}>
{row.map((cellProps, i) => <th {...cellProps} key={i} />)}
</tr>
))
}
</thead>
);
2017-01-11 17:01:50 +08:00
}
};
TableHeader.propTypes = propTypes;
export default TableHeader;