I'm developing mobile app with react-native and react-native-paper.
And I have a problem with Snackbar
component provided react-native-paper.
How can I make snackbar hidden when user touch anywhere?
This is the GIF, I tried to tap many when snackbar is on the bottom of the screen. I would like to it hidden when I tap the screen.
https://gyazo.com/a279a5e9a1b8270e7303446d20c238dc
This is my code.
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { Provider, Snackbar } from 'react-native-paper';
export default class MainScreen extends Component {
constructor(props) {
super(props);
this.state = {
visible: true,
};
this.onDismissSnack = this.onDismissSnack.bind(this);
}
onDismissSnack() {
this.setState({
visible: false
})
}
render() {
return (
<Provider>
<Snackbar
visible={this.state.visible}
onDismiss={() => this.onDismissSnack()}>
<Text>Hello Snackbar</Text>
</Snackbar>
</Provider>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center'
}
});