Reputation: 318
I am fairly new to react-native and I cannot figure out how I can call an event from a custom component. The component I am using is react-native-android-snackbar and I am trying to check if the snackbar is active.
By inspecting the code I have found that there is an event called EVENT_SHOWN. This is exactly what I need but unfortunally I don't know how I can check for this event.
I tried the following:
export default class LoginScreen extends Component {
constructor(props, context) {
super(props, context);
this.state = {username: '', password: '',spinnerVisible:false};
this._event = this._event.bind(this);
DeviceEventEmitter.addListener('EVENT_SHOW',this._event);
}
_event(event: Event){
Alert.alert("Event handler","Event handler");
}
But unfortunally it doesn't work the function doesn't get called when I activate the snackbar.
Hope somebody can help me in the right direction.
Upvotes: 0
Views: 179