I use react-native-paper searchbar component to implement a search component. Following is the basic code I developed. But when I click outside the search input field, the keyboard does not collapse and onFocus is not removed from the input.
import * as React from 'react';
import { Searchbar } from 'react-native-paper';
const SearchBar = () => {
const [searchQuery, setSearchQuery] = React.useState('');
const onChangeSearch = query => setSearchQuery(query);
cons onClick = () => { console.log(`searching for ${query}`);};
return (
<Searchbar
placeholder="Search"
onChangeText={onChangeSearch}
value={searchQuery}
onIconPress={onClick}
/>
);
};
export default SearchBar;
Can somebody please let me know how to hide the keyboard when user click outside the search input? Thanks.