2018-12-22 17:20:04 +03:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import TodoTextInput from './TodoTextInput';
|
|
|
|
|
|
|
|
export default class Header extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
addTodo: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
handleSave = text => {
|
2018-12-22 17:20:04 +03:00
|
|
|
if (text.length !== 0) {
|
|
|
|
this.props.addTodo(text);
|
|
|
|
}
|
2019-01-10 21:51:14 +03:00
|
|
|
};
|
2018-12-22 17:20:04 +03:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2019-01-10 20:23:33 +03:00
|
|
|
<header className="header">
|
2018-12-22 17:20:04 +03:00
|
|
|
<h1>todos</h1>
|
|
|
|
<TodoTextInput
|
|
|
|
newTodo
|
|
|
|
onSave={this.handleSave}
|
2019-01-10 20:23:33 +03:00
|
|
|
placeholder="What needs to be done?"
|
2018-12-22 17:20:04 +03:00
|
|
|
/>
|
|
|
|
</header>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|