<commit_before>var React = require('react')
var ReactDOM = require('react-dom')
var ReactInfinite = require('react-infinite')

var InfiniteAnyHeight = React.createClass({
  getInitialState() {
    return {
      heights: [],
      list: [],
    }
  },

  getScrollContainer() {
    if (this.props.useWindowAsScrollContainer)
      return document.body
    return this.props.scrollContainer
  },

  addHeight(i, height) {
    var heights = this.state.heights
    var scrollDiff = height -heights[i]
    if (scrollDiff && this.scrollTopDelta < 0)
      this.getScrollContainer().scrollTop += scrollDiff
    heights[i] = height
    this.setState({heights})
  },

  componentDidMount() {
    this.setList(this.props.list)
  },

  componentWillReceiveProps(nextProps) {
    if (nextProps.list != this.props.list)
      this.setList(nextProps.list)
  },

  setList(propsList) {
    var heights = []
    var list =
    propsList.map( (x, i)=>{
      heights[i] = this.state.heights[i] || 200
      return (
        <GetHeightWrapper
          addHeight={this.addHeight.bind(this, i)}
          key={i}
        >
          {x}
        </GetHeightWrapper>
      )
    })
    this.setState({
      heights,
      list,
    })
  },

  lastScrollTop: 0,
  scrollTopDelta: 0,

  handleScroll() {
    var scrollTop = this.getScrollContainer().scrollTop
    this.scrollTopDelta = scrollTop -this.lastScrollTop
    this.lastScrollTop = scrollTop
  },

  render() {
    return (
      <ReactInfinite
        elementHeight={this.state.heights}
        handleScroll={this.handleScroll}
        {...this.props}
        >
        {this.state.list}
      </ReactInfinite>
    )
  }
})

var GetHeightWrapper = React.createClass({
  getInitialState() {
    return {height: undefined}
  },

  componentDidMount() {
    this.setHeight()
  },

  setHeight() {
    var height = ReactDOM.findDOMNode(this).getBoundingClientRect().height
    this.props.addHeight(height)
  },
  render() {
    var s = {
      content: ' ',
      display: 'block',
      clear: 'both',
    }
    return (
      <span style={s} className={this.state.height +'-px'}>
        {this.props.children}
      </span>
    )
  }
})

module.exports = InfiniteAnyHeight<commit_msg>Remove soon-to-deprecate findDOMNode.<commit_after>var React = require('react')
var ReactInfinite = require('react-infinite')

var InfiniteAnyHeight = React.createClass({
  getInitialState() {
    return {
      heights: [],
      list: [],
    }
  },

  getScrollContainer() {
    if (this.props.useWindowAsScrollContainer)
      return document.body
    return this.props.scrollContainer
  },

  addHeight(i, height) {
    var heights = this.state.heights
    var scrollDiff = height -heights[i]
    if (scrollDiff && this.scrollTopDelta < 0)
      this.getScrollContainer().scrollTop += scrollDiff
    heights[i] = height
    this.setState({heights})
  },

  componentDidMount() {
    this.setList(this.props.list)
  },

  componentWillReceiveProps(nextProps) {
    if (nextProps.list != this.props.list)
      this.setList(nextProps.list)
  },

  setList(propsList) {
    var heights = []
    var list =
    propsList.map( (x, i)=>{
      heights[i] = this.state.heights[i] || 200
      return (
        <GetHeightWrapper
          addHeight={this.addHeight.bind(this, i)}
          key={i}
        >
          {x}
        </GetHeightWrapper>
      )
    })
    this.setState({
      heights,
      list,
    })
  },

  lastScrollTop: 0,
  scrollTopDelta: 0,

  handleScroll() {
    var scrollTop = this.getScrollContainer().scrollTop
    this.scrollTopDelta = scrollTop -this.lastScrollTop
    this.lastScrollTop = scrollTop
  },

  render() {
    return (
      <ReactInfinite
        elementHeight={this.state.heights}
        handleScroll={this.handleScroll}
        {...this.props}
        >
        {this.state.list}
      </ReactInfinite>
    )
  }
})

var GetHeightWrapper = React.createClass({
  getInitialState() {
    return {height: undefined}
  },

  componentDidMount() {
    this.setHeight()
  },

  setHeight() {
    var height = this.node.getBoundingClientRect().height
    this.props.addHeight(height)
  },
  render() {
    var s = {
      content: ' ',
      display: 'block',
      clear: 'both',
    }
    return (
      <span ref={node => this.node = node}
          style={s} className={this.state.height +'-px'}>
        {this.props.children}
      </span>
    )
  }
})

module.exports = InfiniteAnyHeight
{'fraction_non_alphanumeric': 0.13515940727436013, 'fraction_numerical': 0.002694207453973956, 'mean_word_length': 2.456167571761055, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, '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': '2819014', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1428, 'n_words': 243}