<commit_before>const React = require('react')
const PaperUtils = require('./paperutils.js')
const PaperSet = require('./paperset.jsx')
const Feedback = require('./feedback.jsx')
const AppState = require('./appstate.js')

class SearchResult extends React.Component {
  constructor () {
    super()
    this.state = {
      err: null,
      result: null,
      loading: false,
      query: '',
      renderListAnimation: 0
    }
    if (AppState.getState().serverrender) {
      this.state.server = true
      let query = AppState.getState().serverrender.query
      if (query) {
        this.state.result = query.result
        this.state.query = query.query
      }
    }
    this.mapResultListAnimation = this.mapResultListAnimation.bind(this)
    this.nextFrameUpdate = null
  }
  componentDidMount () {
    if (AppState.getState().serverrender) return
    if (typeof this.props.query === 'string') {
      this.query(this.props.query)
    }
  }
  componentWillReceiveProps (nextProps) {
    if (this.props.query !== nextProps.query) {
      this.query(nextProps.query)
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return nextState.err !== this.state.err
      || nextState.result !== this.state.result
      || nextState.loading !== this.state.loading
      || nextState.query !== this.state.query
      || nextState.renderListAnimation !== this.state.renderListAnimation
  }
  query (query) {
    this.setState({query: query})
    this.props.onStateChange && this.props.onStateChange(true)
    this.setState({err: null, loading: true})
    fetch('/search/' + encodeURIComponent(query) + '/').then(res => res.json()).then(result => {
      if (result.response === 'error') {
        this.error(query, result.err)
        return
      }
      this.result(query, result)<commit_msg>Bugfix: not updating for responsive UI<commit_after>const React = require('react')
const PaperUtils = require('./paperutils.js')
const PaperSet = require('./paperset.jsx')
const Feedback = require('./feedback.jsx')
const AppState = require('./appstate.js')

class SearchResult extends React.Component {
  constructor () {
    super()
    this.state = {
      err: null,
      result: null,
      loading: false,
      query: '',
      renderListAnimation: 0
    }
    if (AppState.getState().serverrender) {
      this.state.server = true
      let query = AppState.getState().serverrender.query
      if (query) {
        this.state.result = query.result
        this.state.query = query.query
      }
    }
    this.mapResultListAnimation = this.mapResultListAnimation.bind(this)
    this.nextFrameUpdate = null
  }
  componentDidMount () {
    if (AppState.getState().serverrender) return
    if (typeof this.props.query === 'string') {
      this.query(this.props.query)
    }
  }
  componentWillReceiveProps (nextProps) {
    if (this.props.query !== nextProps.query) {
      this.query(nextProps.query)
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return nextState.err !== this.state.err
      || nextState.result !== this.state.result
      || nextState.loading !== this.state.loading
      || nextState.query !== this.state.query
      || nextState.renderListAnimation !== this.state.renderListAnimation
      || nextProps.smallerSetName !== this.props.smallerSetName
      || nextProps.query !== this.props.query
  }
  query (query) {
    this.setState({query: query})
    this.props.onStateChange && this.props.onStateChange(true)
    this.setState({err: null, loading: true})
    fetch('/search/' + encodeURIComponent(query) + '/').then(res => res.json()).then(result => {
      if (result.response === 'error') {
        this.error(query, result.err)
        return
      }
      this.result(query, result)
{'fraction_non_alphanumeric': 0.14209258763714208, 'fraction_numerical': 0.0005351886540005352, 'mean_word_length': 2.976595744680851, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2448010', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1108, 'n_words': 206}