import { SearchIcon } from "@chakra-ui/icons"; import { InputGroup, InputLeftElement, Input, forwardRef, } from "@chakra-ui/react"; import { FormEventHandler, useState } from "react"; import { Form } from "../../../components/Form"; import { useDebounce } from "../../../hooks/useDebounce"; export interface SearchInputProps { value: string; onChange: (s: string) => void; onSubmit: FormEventHandler; } export const SearchInput = forwardRef( ({ value, onChange, onSubmit }, inputRef) => { const [inputValue, setInputValue] = useState(value); useDebounce(inputValue, { onChange }); return (
setInputValue(e.target.value)} placeholder="Search" ref={inputRef} value={inputValue} variant="filled" />
); } ); SearchInput.displayName = "SearchInput";