const [text, setText] = useState("");
<input
onChange={(e) => setText(e.target.value)}
value={text}
/>
const inputRef = useRef(null);
const searchHandler = (e) =>
~~
~~
inputRef.current.value = "";
}
};
<input
onKeyDown={searchHandler}
ref={inputRef}
/>