<commit_before>import React from 'react'

export default class Prefs extends React.Component {
  static propTypes = {
    prefs: React.PropTypes.object.isRequired,
    setPrefs: React.PropTypes.func.isRequired,
    providerRefresh: React.PropTypes.func.isRequired,
  }

  toggleEnabled = this.toggleEnabled.bind(this)
  handleRefresh = this.handleRefresh.bind(this)

  toggleEnabled(e) {
    e.preventDefault()
    let prefs = Object.assign({}, this.props.prefs)
    prefs.enabled = !prefs.enabled
    this.props.setPrefs('provider.cdg', prefs)
  }

  handleRefresh() {
    this.props.providerRefresh('cdg')
  }

  render() {
    const { prefs } = this.props
    let paths = prefs.paths || []

    paths = paths.map(path => (
      <p key={path}>{path}</p>
    ))

    return (
      <div>
        <label>
          <input type='checkbox' checked={prefs.enabled} onClick={this.toggleEnabled}/>
          <strong> CD+Graphics</strong>
        </label>
        <button onClick={this.handleRefresh}>Refresh</button>
        {paths}
      </div>
    )
  }
}<commit_msg>Fix rendering before prefs loaded<commit_after>import React from 'react'

export default class Prefs extends React.Component {
  static propTypes = {
    prefs: React.PropTypes.object.isRequired,
    setPrefs: React.PropTypes.func.isRequired,
    providerRefresh: React.PropTypes.func.isRequired,
  }

  toggleEnabled = this.toggleEnabled.bind(this)
  handleRefresh = this.handleRefresh.bind(this)

  toggleEnabled(e) {
    e.preventDefault()
    let prefs = Object.assign({}, this.props.prefs)
    prefs.enabled = !prefs.enabled
    this.props.setPrefs('provider.cdg', prefs)
  }

  handleRefresh() {
    this.props.providerRefresh('cdg')
  }

  render() {
    const { prefs } = this.props
    if (!prefs) return null

    const enabled = prefs.enabled === true
    let paths = prefs.paths || []

    paths = paths.map(path => (
      <p key={path}>{path}</p>
    ))

    return (
      <div>
        <label>
          <input type='checkbox' checked={enabled} onClick={this.toggleEnabled}/>
          <strong> CD+Graphics</strong>
        </label>
        <button onClick={this.handleRefresh}>Refresh</button>
        {paths}
      </div>
    )
  }
}
{'fraction_non_alphanumeric': 0.13763537906137185, 'fraction_numerical': 0.0, 'mean_word_length': 2.862369337979094, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '2263001', 'n_tokens_mistral': 710, 'n_tokens_neox': 695, 'n_words': 130}