I'm trying to populate the input field with the presented searched value when there is being clicked on one of the search results.
I'm fairly new to React FC and Typescript. I'm not sure how exactly is being done. This is what I have tried with the click handler, but the click handler doesn't populate the input field with the value that is being click on.
const [searchTerm, setSearchTerm] = React.useState<string>('');
const [results, setResults] = React.useState<string[]>([]);
const handleClick = () => {
setSearcTerm(searchTerm);
};
React.useEffect(() => {}
return(
<Input
onChange={(event) => setSearchTerm(event.target.value)}
value={searchTerm}
type="search"
/>
{results.length > 0 && (
{results.map((result, index) => (
<div key={index}>
<div onClick={handleClick}> {result}</div>
</div>
))}
)