import * as React from "react"; type Props = { onAdd: (text: string) => void }; export const Input = ({ onAdd }: Props) => { const [text, setText] = React.useState(""); const sendText = (e: React.KeyboardEvent) => { if (e.key !== "Enter") return; onAdd(text); setText(""); }; return (
setText(e.target.value)} onKeyDown={sendText} />
); };