import React, { Component, PropTypes } from 'react' import classnames from 'classnames' import { Key } from '../../utils' export default class ToggleInputButton extends Component { static propTypes = { name: PropTypes.string.isRequired, txt: PropTypes.string.isRequired, onToggleChanged: PropTypes.func.isRequired } constructor(props) { super(props) this.state = { txt: props.txt } } onChange(e) { this.setState({ txt: e.target.value }) } onKeyDown(e) { e.stopPropagation() if (e.keyCode === Key.ENTER) { this.props.onToggleChanged(this.state.txt) } } render() { return (
this.props.onToggleChanged(this.state.txt)}>
  {this.props.name}
this.onChange(e)} onKeyDown={e => this.onKeyDown(e)} />
) } }