<commit_before>require("./add-item.styl")

import React from "react"
import {Button} from "react-bootstrap"

const ENTER_KEYCODE = 13;

export default class AddItem extends React.Component {
  constructor() {
    this.state = {
      newItem: ""
    }
  }

  updateNewItem(event) {
    this.setState({
      newItem: event.target.value
    })
  }

  handleAddNew() {
    let {newItem} = this.state;  //let newItem = this.state.newItem;

    if (newItem.length === 0) {
      return
    }

    this.props.addNew(newItem)

    this.setState({
      newItem: ""
    })
  }

  handleKeyUp(event) {
    event.preventDefault();

    if (event.keyCode === ENTER_KEYCODE) {
      this.handleAddNew()
    }
  }

  render() {
    return <div>
      <input type="text" value={this.state.newItem} onChange={this.updateNewItem} onKeyUp={this.handleKeyUp} />
      <Button onClick={this.props.handleNextDay}>Done</Button>
      <Button onClick={this.props.revealActual}>Reveal</Button>
      </div>
  }
}<commit_msg>Fix issue where input events are not bound to component.<commit_after>require("./add-item.styl")

import React from "react"
import {Button} from "react-bootstrap"

const ENTER_KEYCODE = 13;

export default class AddItem extends React.Component {
  constructor() {
    this.state = {
      newItem: ""
    }
  }

  updateNewItem(event) {
    this.setState({
      newItem: event.target.value
    })
  }

  handleAddNew() {
    let {newItem} = this.state;  //let newItem = this.state.newItem;

    if (newItem.length === 0) {
      return
    }

    this.props.addNew(newItem)

    this.setState({
      newItem: ""
    })
  }

  handleKeyUp(event) {
    event.preventDefault();

    if (event.keyCode === ENTER_KEYCODE) {
      this.handleAddNew()
    }
  }

  render() {
    return <div>
      <input
        type="text" value={this.state.newItem}
        onChange={this.updateNewItem.bind(this)}
        onKeyUp={this.handleKeyUp.bind(this)}
      />

      <Button onClick={this.props.handleNextDay}>Done</Button>
      <Button onClick={this.props.revealActual}>Reveal</Button>
      </div>
  }
}
{'fraction_non_alphanumeric': 0.1442857142857143, 'fraction_numerical': 0.002857142857142857, 'mean_word_length': 2.698943661971831, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5980500', 'n_tokens_mistral': 723, 'n_tokens_neox': 704, 'n_words': 125}