summaryrefslogtreecommitdiffstats
path: root/src/components/Form/TextArea/TextArea.tsx
blob: b8894ab6d96bf2e3f3476ed26b7f025916718a28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { ChangeEvent, ReactElement, SetStateAction } from 'react';
import styles from '../Form.module.scss';

const TextArea = ({
  id,
  name,
  value,
  setValue,
  label,
}: {
  id: string;
  name: string;
  value: string;
  setValue: (value: SetStateAction<string>) => void;
  label?: ReactElement;
}) => {
  const updateValue = (e: ChangeEvent<HTMLTextAreaElement>) => {
    setValue(e.target.value);
  };

  return (
    <>
      {label}
      <textarea
        id={id}
        name={name}
        value={value}
        onChange={updateValue}
        className={`${styles.field} ${styles.textarea}`}
      />
    </>
  );
};

export default TextArea;