import * as classnames from "classnames" import * as React from "react" export default class TodoTextInput extends React.PureComponent { public state = { text: this.props.text || "" } public handleSubmit = (e: any) => { const text = e.target.value.trim() if (e.which === 13) { this.props.onSave(text) if (this.props.newTodo) { this.setState({ text: "" }) } } } public handleChange = (e: any) => { this.setState({ text: e.target.value }) } public handleBlur = (e: any) => { if (!this.props.newTodo) { this.props.onSave(e.target.value) } } public render() { return ( ) } }