import React from 'react';

class TodoCreator extends React.Component<any, any> {

    public onKeyDownFn = (ev: any) => {
        // console.log(ev, ev.target.value, ev.key);
        const { value } = ev.target;
        if (ev.key === `Enter` && value) {

            this.props.addTodo(value);
            ev.target.value = '';
        }
    }

    public render() {
        return (
            <input onKeyDown={this.onKeyDownFn} placeholder={`按下键盘Enter以确定`} />
        );
    }
}
export default TodoCreator;
