import React from 'react'
import { FixedSizeList } from 'react-window';


export class TableRows extends React.Component {
  state = {
    sorting: false,
  }

  rows = this.props.rows

  componentWillReceiveProps(newProps) {
    this.setState(
      {
        sorting: true,
      },
      () => {
        setTimeout(() => {
          this.rows = newProps.rows
          this.setState(
            {
              sorting: true,
            },
            () => {
              this.setState({
                sorting: false,
              })
            },
          )
        }, 500)
      },
    )
  }

  render() {
    const { props, state } = this

    return this.rows.map((Row, index) => (
      // NOTE: No other value to use than index for key.
      <Row index={index} key={index} sorting={state.sorting} />
    ))
  }
}
