mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-12-02 06:23:53 +03:00
33 lines
658 B
TypeScript
33 lines
658 B
TypeScript
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);
|
|
}
|
|
};
|
|
|
|
render() {
|
|
return (
|
|
<header className="header">
|
|
<h1>todos</h1>
|
|
<TodoTextInput
|
|
newTodo
|
|
onSave={this.handleSave}
|
|
placeholder="What needs to be done?"
|
|
/>
|
|
</header>
|
|
);
|
|
}
|
|
}
|