blob: e6085fdc353b38cfd7e75600afe35062250aa043 (
plain) (
blame)
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
|
import { useForm } from 'react-hook-form';
/**
* @typedef {Object} SearchBoxPropsFields
* @property {function} onSearch
*/
/**
* @typedef {SearchBoxPropsFields} SearchBoxProps
*/
/**
* @param {SearchBoxProps} props
*/
function SearchBox({ onSearch }) {
const { register, handleSubmit, formState: { errors }, } = useForm();
/** @type { import('react-hook-form').SubmitHandler<import('react-hook-form').FieldValues> } */
let onSubmit = ( values ) => {
onSearch(values.search);
};
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input className="text" type="text"
placeholder="Search..." {...register('search')} />
<input data-testid="submit" type="submit" hidden />
</form>
);
}
export default SearchBox;
|