<commit_before>import React, { Component, PropTypes } from 'react';
import ReactPaginate from 'react-paginate';
import { rowsValuesToString } from '../utils/convert';


require('./query-result-table.scss');


export default class QueryResultTable extends Component {
  static propTypes = {
    onCopyToClipboardClick: PropTypes.func.isRequired,
    resultItemsPerPage: PropTypes.number.isRequired,
    copied: PropTypes.bool,
    query: PropTypes.string,
    fields: PropTypes.array,
    rows: PropTypes.array,
    rowCount: PropTypes.oneOfType([
      React.PropTypes.array,
      React.PropTypes.number,
    ]),
  }

  constructor(props, context) {
    super(props, context);
    this.state = { currentPage: 1 };
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.copied) {
      this.setState({ showCopied: true });
    }
  }

  componentDidUpdate() {
    if (this.state.showCopied) {
      /* eslint react/no-did-update-set-state: 0 */
      setTimeout(() => this.setState({ showCopied: false }), 1000);
    }
  }

  handlePageClick({ selected: pageIndex }) {
    this.setState({ currentPage: pageIndex + 1 });
  }

  renderQueryResultRows({ fields, rows, rowCount }) {
    if (!rowCount) {
      return (
        <tr>
          <td colSpan={fields.length}>No results found</td>
        </tr>
      );
    }

    return rowsValuesToString(rows).map((row, index) => {
      const columnNames = Object.keys(row);
      return (
        <tr key={index}>
          {columnNames.map(name => {
            return <td key={name}>{row[name]}</td>;
          })}
        </tr>
      );
    });
  }

  render() {
    const { rows, fields, rowCount, resultItemsPerPage, onCopyToClipboardClick } = this.props;<commit_msg>Fixes #111<commit_after>import React, { Component, PropTypes } from 'react';
import ReactPaginate from 'react-paginate';
import { rowsValuesToString } from '../utils/convert';


require('./query-result-table.scss');


export default class QueryResultTable extends Component {
  static propTypes = {
    onCopyToClipboardClick: PropTypes.func.isRequired,
    resultItemsPerPage: PropTypes.number.isRequired,
    copied: PropTypes.bool,
    query: PropTypes.string,
    fields: PropTypes.array,
    rows: PropTypes.array,
    rowCount: PropTypes.oneOfType([
      React.PropTypes.array,
      React.PropTypes.number,
    ]),
  }

  constructor(props, context) {
    super(props, context);
    this.state = { currentPage: 1 };
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.copied) {
      this.setState({ showCopied: true });
    }
  }

  componentDidUpdate() {
    if (this.state.showCopied) {
      /* eslint react/no-did-update-set-state: 0 */
      setTimeout(() => this.setState({ showCopied: false }), 1000);
    }
  }

  handlePageClick({ selected: pageIndex }) {
    this.setState({ currentPage: pageIndex + 1 });
  }

  renderQueryResultRows({ fields, rows, rowCount }) {
    if (!rowCount) {
      return (
        <tr>
          <td colSpan={fields.length}>No results found</td>
        </tr>
      );
    }

    return rowsValuesToString(rows).map((row, index) => {
      return (
        <tr key={index}>
          {fields.map(({ name }) => {
            return <td key={name}>{row[name]}</td>;
          })}
        </tr>
      );
    });
  }

  render() {
    const { rows, fields, rowCount, resultItemsPerPage, onCopyToClipboardClick } = this.props;
{'fraction_non_alphanumeric': 0.1426893716970053, 'fraction_numerical': 0.0049911920140927775, 'mean_word_length': 2.7897664071190214, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2265815', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1055, 'n_words': 208}