notification + callBacks functions

i’m usign expo push notification logic, i receive the notifications fine, but i need that when notification in foregournd are received execute specifics functions in certain components. My notification logic is in a Main.js to handle all notifications, but then i need to send some data to other component to reload info, but as the component was already mounted data never arrived.

So Main.js handle notifications and knows OrdersComponent by navigator.
In Main.js i have the _handleNotification function that catch all notifications pretty fine.

I’m using a createBottomTabNavigator element to handle screens

_handleNotification = (notification) => {
if( && &&{
this.props.navigation.navigate('OrdersComponent ', {refreshData: true});

I’m not sure if it’s officially supported but I have found that you can register multiple notification listeners, so you can register more handlers in other components.

yep i also achieved this, buut one thing is that all listeners are “global” so i do not know if that affect performance, in my case is just about 2 listeners, or 3 maybe, but would be perfect if was one and manage states.

One thought is using like a main component, loading the other components by state var, like a switch, so you can pass state value and change it with notification received to send data to the required component and make whatever you want depending of that parameter passed by parent main component

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.