blob: e63a19ee873a32cd0e706098ce50f4d80e240b51 (
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 } = 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
|