redux-devtools/packages/redux-devtools-slider-monitor/examples/todomvc/components/Header.tsx

33 lines
658 B
TypeScript
Raw Normal View History

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