I am using socket.io(server) and socket.io-client(client) in react-native app and I am listening to its events in useEffect hook, all events are receiving correctly when I am on that specific component.
So how can can I receive these events on the other screens too??
Single instance for all events which will be used globally
e.g:
const app = () => {
useEffect(() => {
socket.on('event', (data) => {
console.log(data)
}
},[])
...................
rest of the code
...................
}
Now I want to listen to this event on all the screens (like DeviceEventEmitter addListner works)?
Thanks.