Input.tsx 480 B

123456789101112131415161718
  1. import React, { useState } from 'react';
  2. interface InputProps {
  3. placeholder?: string;
  4. onChange: (value: string) => void;
  5. }
  6. // TODO: Add validation
  7. export function Input({ placeholder, onChange }: InputProps) {
  8. const [value, setValue] = useState('');
  9. function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
  10. setValue(e.target.value);
  11. onChange(e.target.value);
  12. }
  13. return <input value={value} onChange={handleChange} placeholder={placeholder} />;
  14. }