fleet/frontend/components/queries/QueryResultsTable/QueryResultsRow.jsx
Zachary Wasserman dc4b97d15f
Fix React deprecation warnings (#1976)
- Refactor imports of PropTypes to use the prop-types package
- Upgrade dependencies that were setting off deprecation warnings
2019-01-06 17:25:33 -08:00

34 lines
948 B
JavaScript

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { isEqual, omit, values } from 'lodash';
import queryResultInterface from 'interfaces/query_result';
class QueryResultsRow extends Component {
static propTypes = {
index: PropTypes.number.isRequired,
queryResult: queryResultInterface.isRequired,
};
shouldComponentUpdate (nextProps) {
return !isEqual(this.props.queryResult, nextProps.queryResult);
}
render () {
const { index, queryResult } = this.props;
const { host_hostname: hostHostname } = queryResult;
const queryAttrs = omit(queryResult, ['host_hostname']);
const queryAttrValues = values(queryAttrs);
return (
<tr>
<td>{hostHostname}</td>
{queryAttrValues.map((attribute, i) => {
return <td key={`query-results-table-row-${index}-${i}`}>{attribute}</td>;
})}
</tr>
);
}
}
export default QueryResultsRow;