class NumericInput extends React.Component {
  constructor(props = {}) {
    super(props)
    this.state = {
      value: numeral(props.value).format('0,0')
    }
  }

  onChange(e) {
    var number = numeral().unformat(e.target.value)
    var string = numeral(number).format('0,0')
    this.setState({ value: string })
    this.props.onChange(number)
  }

  render() {
    return (
      <input 
        className="form-control" 
        type="text" 
        placeholder={this.props.placeholder} 
        value={this.state.value}
        onChange={this.onChange.bind(this)}/>)
  }
}