I have a React Web app where I listen to events on the Web socket and update my components upon getting a message on the web socket. I want to show a visual notification when I receive a new event. I came across this library (http://ift.tt/2xe3WWJ) and in the documentation the notification is triggered upon clicking a button. However I want to trigger a notification immediately upon receiving a new event on web socket.
My implementation as of now is as follows. This is under the render() method:
createNotification = (type) => {
return () => {
switch (type) {
case 'info':
NotificationManager.info('New Log Arrived', 5000);
break;
case 'warning':
NotificationManager.warning('Warning message', 3000);
break;
};
I set the below under my websocket method:
{this.createNotification('info')}
However I get an error. How should this be implemented so that its triggered automatically once I get a message on the web socket?
Aucun commentaire:
Enregistrer un commentaire