blob: 07f041099126af258cc9fa69cdfd0c5075f1d0a5 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import {
ChangeEvent,
ForwardedRef,
forwardRef,
ReactElement,
SetStateAction,
} from 'react';
import styles from '../Form.module.scss';
type InputType = 'text' | 'email' | 'number' | 'search';
const Input = (
{
id,
name,
value,
setValue,
type = 'text',
label,
}: {
id: string;
name: string;
value: string;
setValue: (value: SetStateAction<string>) => void;
type?: InputType;
label?: ReactElement;
},
ref: ForwardedRef<HTMLInputElement>
) => {
const updateValue = (e: ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
};
return (
<>
{label}
<input
ref={ref}
type={type}
id={id}
name={name}
value={value}
onChange={updateValue}
className={styles.field}
/>
</>
);
};
export default forwardRef(Input);
|