Hide / disable popup on certain components
nica0012 opened this issue · comments
Hi, first of all thanks for a great module.
Is it possible to hide the popup sometimes, for example when you get a message notification while you're already on the messages screen / component?
Cheers.
Hi, it is up to you when you call the show()
method. You need to wrap it in an if
statement that checks the condition you specify, currentScreen === "messages"
for example.
Hi @nica0012. For such use case, following React paradigm, I think you should put the additional logic in this.popup.show()
. You may use some global stores such as Redux and MobX to store (for example) the screen you are on.
E.g.
class MyComponent extends React.Component {
onMessage = () => {
if (this.stores.appState.currentScreen==='MessagesPage') return; // Don't show the popup
this.popup.show();
}
render() {
return (
<View>
<NotificationPopup ref={ref => this.popup = ref} />
<MaybeYourNavigator />
</View>
);
}
}
export default inject('stores')(MyComponent);