import React from "react"; import * as PropTypes from "prop-types"; // Header component to be used as default for all the columns. export default class SortableHeaderComponent extends React.Component { constructor(props) { super(props); // this.sortChanged = this.onSortChanged.bind(this); this.props.column.addEventListener('sortChanged', this.onSortChanged); //The state of this component contains the current sort state of this column //The possible values are: 'asc', 'desc' and '' this.state = { sorted: '' } } componentWillUnmount() { this.props.column.removeEventListener('sortChanged', this.onSortChanged); } render() { let sortElements = []; if (this.props.enableSorting) { let downArrowClass = "customSortDownLabel " + (this.state.sorted === 'desc' ? " active" : ""); let upArrowClass = "customSortUpLabel " + (this.state.sorted === 'asc' ? " active" : ""); let removeArrowClass = "customSortRemoveLabel " + (this.state.sorted === '' ? " active" : ""); sortElements.push(