-1
I’m trying to make the virtual keyboard disappear when I press any part of the screen in React Native, but it doesn’t work.
I have tried to put this function in the views, Texts and even create a constant on the outside with TouchableWithoutFeedback
, but nothing, what can I do?
export default function StatusFile() {
const searchBar = React.createRef();
const [search, setSearch] = useState('');
return(
<View style={styles.container} onPress={**() => Keyboard.dismiss()**}>
<ScrollView style={styles.scroll}>
<SearchBar
text={search}
ref={searchBar}
placeholder='Procurar...'
barStyle='black'
textFieldBackgroundColor='#FF8C00'
onChangeText={setSearch}
onSearchButtonPress={() => searchBar.current.blur()}
/>
{search !== '' ?
statusFile.filter(a => a.toLowerCase().indexOf(search.toLowerCase()) !== -1).map(a => (
<Text style={styles.texto} key={a}>
{a}
</Text>
))
:
<Text style={styles.texto}>Faça uma busca pelo status, EX: 10</Text>
}
</ScrollView>
</View>
);
Rafael, thank you very much, solved my problem and also showed that I need to deepen more in the properties of the elements I use, a hug.
– Wander